<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">

<title>module FileUtils - fileutils: Ruby Standard Library Documentation</title>


<script src="./js/navigation.js" defer></script>
<script src="./js/search.js" defer></script>
<script src="./js/search_index.js" defer></script>
<script src="./js/searcher.js" defer></script>
<script src="./js/darkfish.js" defer></script>

<script src="./js/jquery-3.2.0.min.js"></script>

<script src="./js/vue.min.js"></script>
<script src="./js/js.cookie.min.js"></script>

<link href="./css/fonts.css" rel="stylesheet">
<link id='rdoccss' href="./css/rdoc.css" rel="stylesheet">
<link href="./css/carbon17.css" rel="stylesheet">

<script type="text/javascript">
  var rdoc_rel_prefix = "./";
  var index_rel_prefix = "./";
  var darkModeCsseHref = "./css/rdoc-dm.css"
  var defaultModeCssHref = "./css/rdoc.css"
  // var cssDarkmode = Cookies.get('darkmode');
  
  if( Cookies.get("darkmode") == "true") {
	$('#rdoccss').attr("href", darkModeCsseHref);
}

//  https://cssdeck.com/blog/simple-jquery-stylesheet-switcher/

document.write('<style type="text/css">body{display:none}</style>');

</script>


</head>
<body id="top" role="document" class="module">
  <!-- this is class.html -->

  <div id='actionbar' >
    <div class='wrapper mdiv'>
      <ul class='grids g0'></ul>
    </div> 
    <!-- VERSION HEADER for 3.3.0.preview2 NOT FOUND -->
  </div> <!-- end action bar -->

  <div class='wrapper hdiv'>

    


    <nav id='vapp' role="navigation">
    <div id="project-navigation">
      <div id="home-section" role="region" title="Quick navigation" class="nav-section">
  <h2><a href="./index.html" rel="home">Home</a></h2>

  <div id="table-of-contents-navigation"  >
    <a href="./table_of_contents.html#pages">Pages</a>
    <a href="./table_of_contents.html#classes">Classes</a>
    <a href="./table_of_contents.html#methods">Methods</a>
  </div>
</div>

      <div id="search-section" role="search" class="project-section initially-hidden">
  <form action="#" method="get" accept-charset="utf-8">
    <div id="search-field-wrapper">
      <input id="search-field" role="combobox" aria-label="Search"
             aria-autocomplete="list" aria-controls="search-results"
             type="text" name="search" placeholder="Search" spellcheck="false"
             title="Type to search, Up and Down to navigate, Enter to load">
    </div>

    <ul id="search-results" aria-label="Search Results"
        aria-busy="false" aria-expanded="false"
        aria-atomic="false" class="initially-hidden"></ul>
  </form>
</div>

    </div>


    
<div class="nav-section">
  <h3>Table of Contents</h3>

  <ul class="link-list" role="directory">
    <li><a href="#module-FileUtils-label-What-27s+Here">What’s Here</a>
    <li><a href="#module-FileUtils-label-Creating">Creating</a>
    <li><a href="#module-FileUtils-label-Deleting">Deleting</a>
    <li><a href="#module-FileUtils-label-Querying">Querying</a>
    <li><a href="#module-FileUtils-label-Setting">Setting</a>
    <li><a href="#module-FileUtils-label-Comparing">Comparing</a>
    <li><a href="#module-FileUtils-label-Copying">Copying</a>
    <li><a href="#module-FileUtils-label-Moving">Moving</a>
    <li><a href="#module-FileUtils-label-Options">Options</a>
    <li><a href="#module-FileUtils-label-Path+Arguments">Path Arguments</a>
    <li><a href="#module-FileUtils-label-About+the+Examples">About the Examples</a>
    <li><a href="#module-FileUtils-label-Avoiding+the+TOCTTOU+Vulnerability">Avoiding the TOCTTOU Vulnerability</a>
  </ul>
</div>


    <button id='toggleThing' @click="toggleNav()" >Show/hide navigation</button>
    <div :class="isOpen ? 'block' : 'hidden' " id='toggleMe'>
      <div id="class-metadata">
        
        
        
<div id="includes-section" class="nav-section">
  <h3>Included Modules</h3>

  <ul class="link-list">
    <li><a class="include" href="FileUtils/StreamUtils_.html">FileUtils::StreamUtils_</a>
  </ul>
</div>

        
<div id="extends-section" class="nav-section">
  <h3>Extended With Modules</h3>

  <ul class="link-list">
    <li><a class="extend" href="FileUtils/StreamUtils_.html">FileUtils::StreamUtils_</a>
  </ul>
</div>

        
<!-- Method Quickref -->
<div id="method-list-section" class="nav-section">
  <h3>Methods</h3>

  <ul class="link-list" role="directory">
    <li ><a href="#method-c-cd">::cd</a>
    <li ><a href="#method-c-chdir">::chdir</a>
    <li ><a href="#method-c-chmod">::chmod</a>
    <li ><a href="#method-c-chmod_R">::chmod_R</a>
    <li ><a href="#method-c-chown">::chown</a>
    <li ><a href="#method-c-chown_R">::chown_R</a>
    <li ><a href="#method-c-cmp">::cmp</a>
    <li ><a href="#method-c-collect_method">::collect_method</a>
    <li ><a href="#method-c-commands">::commands</a>
    <li ><a href="#method-c-compare_file">::compare_file</a>
    <li ><a href="#method-c-compare_stream">::compare_stream</a>
    <li ><a href="#method-c-copy">::copy</a>
    <li ><a href="#method-c-copy_entry">::copy_entry</a>
    <li ><a href="#method-c-copy_file">::copy_file</a>
    <li ><a href="#method-c-copy_stream">::copy_stream</a>
    <li ><a href="#method-c-cp">::cp</a>
    <li ><a href="#method-c-cp_lr">::cp_lr</a>
    <li ><a href="#method-c-cp_r">::cp_r</a>
    <li ><a href="#method-c-getwd">::getwd</a>
    <li ><a href="#method-c-have_option-3F">::have_option?</a>
    <li ><a href="#method-c-identical-3F">::identical?</a>
    <li ><a href="#method-c-install">::install</a>
    <li ><a href="#method-c-link">::link</a>
    <li ><a href="#method-c-link_entry">::link_entry</a>
    <li ><a href="#method-c-ln">::ln</a>
    <li ><a href="#method-c-ln_s">::ln_s</a>
    <li ><a href="#method-c-ln_sf">::ln_sf</a>
    <li ><a href="#method-c-ln_sr">::ln_sr</a>
    <li ><a href="#method-c-makedirs">::makedirs</a>
    <li ><a href="#method-c-mkdir">::mkdir</a>
    <li ><a href="#method-c-mkdir_p">::mkdir_p</a>
    <li ><a href="#method-c-mkpath">::mkpath</a>
    <li ><a href="#method-c-move">::move</a>
    <li ><a href="#method-c-mv">::mv</a>
    <li ><a href="#method-c-options">::options</a>
    <li ><a href="#method-c-options_of">::options_of</a>
    <li ><a href="#method-c-pwd">::pwd</a>
    <li ><a href="#method-c-remove">::remove</a>
    <li ><a href="#method-c-remove_dir">::remove_dir</a>
    <li ><a href="#method-c-remove_entry">::remove_entry</a>
    <li ><a href="#method-c-remove_entry_secure">::remove_entry_secure</a>
    <li ><a href="#method-c-remove_file">::remove_file</a>
    <li ><a href="#method-c-rm">::rm</a>
    <li ><a href="#method-c-rm_f">::rm_f</a>
    <li ><a href="#method-c-rm_r">::rm_r</a>
    <li ><a href="#method-c-rm_rf">::rm_rf</a>
    <li ><a href="#method-c-rmdir">::rmdir</a>
    <li ><a href="#method-c-rmtree">::rmtree</a>
    <li ><a href="#method-c-safe_unlink">::safe_unlink</a>
    <li ><a href="#method-c-symlink">::symlink</a>
    <li ><a href="#method-c-touch">::touch</a>
    <li ><a href="#method-c-uptodate-3F">::uptodate?</a>
    <li ><a href="#method-i-cd">#cd</a>
    <li ><a href="#method-i-chdir">#chdir</a>
    <li ><a href="#method-i-chmod">#chmod</a>
    <li ><a href="#method-i-chmod_R">#chmod_R</a>
    <li ><a href="#method-i-chown">#chown</a>
    <li ><a href="#method-i-chown_R">#chown_R</a>
    <li ><a href="#method-i-cmp">#cmp</a>
    <li ><a href="#method-i-compare_file">#compare_file</a>
    <li ><a href="#method-i-compare_stream">#compare_stream</a>
    <li ><a href="#method-i-copy">#copy</a>
    <li ><a href="#method-i-copy_entry">#copy_entry</a>
    <li ><a href="#method-i-copy_file">#copy_file</a>
    <li ><a href="#method-i-copy_stream">#copy_stream</a>
    <li ><a href="#method-i-cp">#cp</a>
    <li ><a href="#method-i-cp_lr">#cp_lr</a>
    <li ><a href="#method-i-cp_r">#cp_r</a>
    <li ><a href="#method-i-fu_clean_components">#fu_clean_components</a>
    <li ><a href="#method-i-fu_split_path">#fu_split_path</a>
    <li ><a href="#method-i-fu_starting_path-3F">#fu_starting_path?</a>
    <li ><a href="#method-i-getwd">#getwd</a>
    <li ><a href="#method-i-identical-3F">#identical?</a>
    <li ><a href="#method-i-install">#install</a>
    <li ><a href="#method-i-link">#link</a>
    <li ><a href="#method-i-link_entry">#link_entry</a>
    <li ><a href="#method-i-ln">#ln</a>
    <li ><a href="#method-i-ln_s">#ln_s</a>
    <li ><a href="#method-i-ln_sf">#ln_sf</a>
    <li ><a href="#method-i-ln_sr">#ln_sr</a>
    <li ><a href="#method-i-makedirs">#makedirs</a>
    <li ><a href="#method-i-mkdir">#mkdir</a>
    <li ><a href="#method-i-mkdir_p">#mkdir_p</a>
    <li ><a href="#method-i-mkpath">#mkpath</a>
    <li ><a href="#method-i-move">#move</a>
    <li ><a href="#method-i-mv">#mv</a>
    <li ><a href="#method-i-pwd">#pwd</a>
    <li ><a href="#method-i-remove">#remove</a>
    <li ><a href="#method-i-remove_dir">#remove_dir</a>
    <li ><a href="#method-i-remove_entry">#remove_entry</a>
    <li ><a href="#method-i-remove_entry_secure">#remove_entry_secure</a>
    <li ><a href="#method-i-remove_file">#remove_file</a>
    <li ><a href="#method-i-rm">#rm</a>
    <li ><a href="#method-i-rm_f">#rm_f</a>
    <li ><a href="#method-i-rm_r">#rm_r</a>
    <li ><a href="#method-i-rm_rf">#rm_rf</a>
    <li ><a href="#method-i-rmdir">#rmdir</a>
    <li ><a href="#method-i-rmtree">#rmtree</a>
    <li ><a href="#method-i-safe_unlink">#safe_unlink</a>
    <li ><a href="#method-i-symlink">#symlink</a>
    <li ><a href="#method-i-touch">#touch</a>
    <li ><a href="#method-i-uptodate-3F">#uptodate?</a>
  </ul>
</div>

      </div>
     </div>
    </nav>


    <div id='extraz'><div class='adzbox-index'  >
      
     </div>         
    </div>

    <main role="main" aria-labelledby="module-FileUtils">
    <h1 id="module-FileUtils" class="module">
      module FileUtils
    </h1>

    <section class="description">
    
<p>Namespace for file utility methods for copying, moving, removing, etc.</p>

<h2 id="module-FileUtils-label-What-27s+Here">What’s Here<span><a href="#module-FileUtils-label-What-27s+Here">&para;</a> <a href="#top">&uarr;</a></span></h2>

<p>First, what’s elsewhere. Module FileUtils:</p>
<ul><li>
<p>Inherits from class Object.</p>
</li><li>
<p>Supplements class File (but is not included or extended there).</p>
</li></ul>

<p>Here, module FileUtils provides methods that are useful for:</p>
<ul><li>
<p><a href="FileUtils.html#module-FileUtils-label-Creating">Creating</a>.</p>
</li><li>
<p><a href="FileUtils.html#module-FileUtils-label-Deleting">Deleting</a>.</p>
</li><li>
<p><a href="FileUtils.html#module-FileUtils-label-Querying">Querying</a>.</p>
</li><li>
<p><a href="FileUtils.html#module-FileUtils-label-Setting">Setting</a>.</p>
</li><li>
<p><a href="FileUtils.html#module-FileUtils-label-Comparing">Comparing</a>.</p>
</li><li>
<p><a href="FileUtils.html#module-FileUtils-label-Copying">Copying</a>.</p>
</li><li>
<p><a href="FileUtils.html#module-FileUtils-label-Moving">Moving</a>.</p>
</li><li>
<p><a href="FileUtils.html#module-FileUtils-label-Options">Options</a>.</p>
</li></ul>

<h3 id="module-FileUtils-label-Creating">Creating<span><a href="#module-FileUtils-label-Creating">&para;</a> <a href="#top">&uarr;</a></span></h3>
<ul><li>
<p><a href="FileUtils.html#method-c-mkdir"><code>::mkdir</code></a>: Creates directories.</p>
</li><li>
<p><a href="FileUtils.html#method-c-mkdir_p"><code>::mkdir_p</code></a>, <a href="FileUtils.html#method-c-makedirs"><code>::makedirs</code></a>, <a href="FileUtils.html#method-c-mkpath"><code>::mkpath</code></a>: Creates directories, also creating ancestor directories as needed.</p>
</li><li>
<p><a href="FileUtils.html#method-c-link_entry"><code>::link_entry</code></a>: Creates a hard link.</p>
</li><li>
<p><a href="FileUtils.html#method-c-ln"><code>::ln</code></a>, <a href="FileUtils.html#method-c-link"><code>::link</code></a>: Creates hard links.</p>
</li><li>
<p><a href="FileUtils.html#method-c-ln_s"><code>::ln_s</code></a>, <a href="FileUtils.html#method-c-symlink"><code>::symlink</code></a>: Creates symbolic links.</p>
</li><li>
<p><a href="FileUtils.html#method-c-ln_sf"><code>::ln_sf</code></a>: Creates symbolic links, overwriting if necessary.</p>
</li><li>
<p><a href="FileUtils.html#method-c-ln_sr"><code>::ln_sr</code></a>: Creates symbolic links relative to targets</p>
</li></ul>

<h3 id="module-FileUtils-label-Deleting">Deleting<span><a href="#module-FileUtils-label-Deleting">&para;</a> <a href="#top">&uarr;</a></span></h3>
<ul><li>
<p><a href="FileUtils.html#method-c-remove_dir"><code>::remove_dir</code></a>: Removes a directory and its descendants.</p>
</li><li>
<p><a href="FileUtils.html#method-c-remove_entry"><code>::remove_entry</code></a>: Removes an entry, including its descendants if it is a directory.</p>
</li><li>
<p><a href="FileUtils.html#method-c-remove_entry_secure"><code>::remove_entry_secure</code></a>: Like <a href="FileUtils.html#method-c-remove_entry"><code>::remove_entry</code></a>, but removes securely.</p>
</li><li>
<p><a href="FileUtils.html#method-c-remove_file"><code>::remove_file</code></a>: Removes a file entry.</p>
</li><li>
<p><a href="FileUtils.html#method-c-rm"><code>::rm</code></a>, <a href="FileUtils.html#method-c-remove"><code>::remove</code></a>: Removes entries.</p>
</li><li>
<p><a href="FileUtils.html#method-c-rm_f"><code>::rm_f</code></a>, <a href="FileUtils.html#method-c-safe_unlink"><code>::safe_unlink</code></a>: Like <a href="FileUtils.html#method-c-rm"><code>::rm</code></a>, but removes forcibly.</p>
</li><li>
<p><a href="FileUtils.html#method-c-rm_r"><code>::rm_r</code></a>: Removes entries and their descendants.</p>
</li><li>
<p><a href="FileUtils.html#method-c-rm_rf"><code>::rm_rf</code></a>, <a href="FileUtils.html#method-c-rmtree"><code>::rmtree</code></a>: Like <a href="FileUtils.html#method-c-rm_r"><code>::rm_r</code></a>, but removes forcibly.</p>
</li><li>
<p><a href="FileUtils.html#method-c-rmdir"><code>::rmdir</code></a>: Removes directories.</p>
</li></ul>

<h3 id="module-FileUtils-label-Querying">Querying<span><a href="#module-FileUtils-label-Querying">&para;</a> <a href="#top">&uarr;</a></span></h3>
<ul><li>
<p><a href="FileUtils.html#method-c-pwd"><code>::pwd</code></a>, <a href="FileUtils.html#method-c-getwd"><code>::getwd</code></a>: Returns the path to the working directory.</p>
</li><li>
<p><a href="FileUtils.html#method-c-uptodate-3F"><code>::uptodate?</code></a>: Returns whether a given entry is newer than given other entries.</p>
</li></ul>

<h3 id="module-FileUtils-label-Setting">Setting<span><a href="#module-FileUtils-label-Setting">&para;</a> <a href="#top">&uarr;</a></span></h3>
<ul><li>
<p><a href="FileUtils.html#method-c-cd"><code>::cd</code></a>, <a href="FileUtils.html#method-c-chdir"><code>::chdir</code></a>: Sets the working directory.</p>
</li><li>
<p><a href="FileUtils.html#method-c-chmod"><code>::chmod</code></a>: Sets permissions for an entry.</p>
</li><li>
<p><a href="FileUtils.html#method-c-chmod_R"><code>::chmod_R</code></a>: Sets permissions for an entry and its descendants.</p>
</li><li>
<p><a href="FileUtils.html#method-c-chown"><code>::chown</code></a>: Sets the owner and group for entries.</p>
</li><li>
<p><a href="FileUtils.html#method-c-chown_R"><code>::chown_R</code></a>: Sets the owner and group for entries and their descendants.</p>
</li><li>
<p><a href="FileUtils.html#method-c-touch"><code>::touch</code></a>: Sets modification and access times for entries, creating if necessary.</p>
</li></ul>

<h3 id="module-FileUtils-label-Comparing">Comparing<span><a href="#module-FileUtils-label-Comparing">&para;</a> <a href="#top">&uarr;</a></span></h3>
<ul><li>
<p><a href="FileUtils.html#method-c-compare_file"><code>::compare_file</code></a>, <a href="FileUtils.html#method-c-cmp"><code>::cmp</code></a>, <a href="FileUtils.html#method-c-identical-3F"><code>::identical?</code></a>: Returns whether two entries are identical.</p>
</li><li>
<p><a href="FileUtils.html#method-c-compare_stream"><code>::compare_stream</code></a>: Returns whether two streams are identical.</p>
</li></ul>

<h3 id="module-FileUtils-label-Copying">Copying<span><a href="#module-FileUtils-label-Copying">&para;</a> <a href="#top">&uarr;</a></span></h3>
<ul><li>
<p><a href="FileUtils.html#method-c-copy_entry"><code>::copy_entry</code></a>: Recursively copies an entry.</p>
</li><li>
<p><a href="FileUtils.html#method-c-copy_file"><code>::copy_file</code></a>: Copies an entry.</p>
</li><li>
<p><a href="FileUtils.html#method-c-copy_stream"><code>::copy_stream</code></a>: Copies a stream.</p>
</li><li>
<p><a href="FileUtils.html#method-c-cp"><code>::cp</code></a>, <a href="FileUtils.html#method-c-copy"><code>::copy</code></a>: Copies files.</p>
</li><li>
<p><a href="FileUtils.html#method-c-cp_lr"><code>::cp_lr</code></a>: Recursively creates hard links.</p>
</li><li>
<p><a href="FileUtils.html#method-c-cp_r"><code>::cp_r</code></a>: Recursively copies files, retaining mode, owner, and group.</p>
</li><li>
<p><a href="FileUtils.html#method-c-install"><code>::install</code></a>: Recursively copies files, optionally setting mode, owner, and group.</p>
</li></ul>

<h3 id="module-FileUtils-label-Moving">Moving<span><a href="#module-FileUtils-label-Moving">&para;</a> <a href="#top">&uarr;</a></span></h3>
<ul><li>
<p><a href="FileUtils.html#method-c-mv"><code>::mv</code></a>, <a href="FileUtils.html#method-c-move"><code>::move</code></a>: Moves entries.</p>
</li></ul>

<h3 id="module-FileUtils-label-Options">Options<span><a href="#module-FileUtils-label-Options">&para;</a> <a href="#top">&uarr;</a></span></h3>
<ul><li>
<p><a href="FileUtils.html#method-c-collect_method"><code>::collect_method</code></a>: Returns the names of methods that accept a given option.</p>
</li><li>
<p><a href="FileUtils.html#method-c-commands"><code>::commands</code></a>: Returns the names of methods that accept options.</p>
</li><li>
<p><a href="FileUtils.html#method-c-have_option-3F"><code>::have_option?</code></a>: Returns whether a given method accepts a given option.</p>
</li><li>
<p><a href="FileUtils.html#method-c-options"><code>::options</code></a>: Returns all option names.</p>
</li><li>
<p><a href="FileUtils.html#method-c-options_of"><code>::options_of</code></a>: Returns the names of the options for a given method.</p>
</li></ul>

<h2 id="module-FileUtils-label-Path+Arguments">Path Arguments<span><a href="#module-FileUtils-label-Path+Arguments">&para;</a> <a href="#top">&uarr;</a></span></h2>

<p>Some methods in FileUtils accept <em>path</em> arguments, which are interpreted as paths to filesystem entries:</p>
<ul><li>
<p>If the argument is a string, that value is the path.</p>
</li><li>
<p>If the argument has method <code>:to_path</code>, it is converted via that method.</p>
</li><li>
<p>If the argument has method <code>:to_str</code>, it is converted via that method.</p>
</li></ul>

<h2 id="module-FileUtils-label-About+the+Examples">About the Examples<span><a href="#module-FileUtils-label-About+the+Examples">&para;</a> <a href="#top">&uarr;</a></span></h2>

<p>Some examples here involve trees of file entries. For these, we sometimes display trees using the <a href="https://en.wikipedia.org/wiki/Tree_(command)">tree command-line utility</a>, which is a recursive directory-listing utility that produces a depth-indented listing of files and directories.</p>

<p>We use a helper method to launch the command and control the format:</p>

<pre class="ruby"><span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">tree</span>(<span class="ruby-identifier">dirpath</span> = <span class="ruby-string">&#39;.&#39;</span>)
  <span class="ruby-identifier">command</span> = <span class="ruby-node">&quot;tree --noreport --charset=ascii #{dirpath}&quot;</span>
  <span class="ruby-identifier">system</span>(<span class="ruby-identifier">command</span>)
<span class="ruby-keyword">end</span>
</pre>

<p>To illustrate:</p>

<pre class="ruby"><span class="ruby-identifier">tree</span>(<span class="ruby-string">&#39;src0&#39;</span>)
<span class="ruby-comment"># =&gt; src0</span>
<span class="ruby-comment">#    |-- sub0</span>
<span class="ruby-comment">#    |   |-- src0.txt</span>
<span class="ruby-comment">#    |   `-- src1.txt</span>
<span class="ruby-comment">#    `-- sub1</span>
<span class="ruby-comment">#        |-- src2.txt</span>
<span class="ruby-comment">#        `-- src3.txt</span>
</pre>

<h2 id="module-FileUtils-label-Avoiding+the+TOCTTOU+Vulnerability">Avoiding the TOCTTOU Vulnerability<span><a href="#module-FileUtils-label-Avoiding+the+TOCTTOU+Vulnerability">&para;</a> <a href="#top">&uarr;</a></span></h2>

<p>For certain methods that recursively remove entries, there is a potential vulnerability called the <a href="https://en.wikipedia.org/wiki/Time-of-check_to_time-of-use">Time-of-check to time-of-use</a>, or TOCTTOU, vulnerability that can exist when:</p>
<ul><li>
<p>An ancestor directory of the entry at the target path is world writable; such directories include <code>/tmp</code>.</p>
</li><li>
<p>The directory tree at the target path includes:</p>
<ul><li>
<p>A world-writable descendant directory.</p>
</li><li>
<p>A symbolic link.</p>
</li></ul>
</li></ul>

<p>To avoid that vulnerability, you can use this method to remove entries:</p>
<ul><li>
<p><a href="FileUtils.html#method-c-remove_entry_secure"><code>FileUtils.remove_entry_secure</code></a>: removes recursively if the target path points to a directory.</p>
</li></ul>

<p>Also available are these methods, each of which calls FileUtils.remove_entry_secure:</p>
<ul><li>
<p><a href="FileUtils.html#method-c-rm_r"><code>FileUtils.rm_r</code></a> with keyword argument <code>secure: true</code>.</p>
</li><li>
<p><a href="FileUtils.html#method-c-rm_rf"><code>FileUtils.rm_rf</code></a> with keyword argument <code>secure: true</code>.</p>
</li></ul>

<p>Finally, this method for moving entries calls FileUtils.remove_entry_secure if the source and destination are on different file systems (which means that the “move” is really a copy and remove):</p>
<ul><li>
<p><a href="FileUtils.html#method-c-mv"><code>FileUtils.mv</code></a> with keyword argument <code>secure: true</code>.</p>
</li></ul>

<p>Method FileUtils.remove_entry_secure removes securely by applying a special pre-process:</p>
<ul><li>
<p>If the target path points to a directory, this method uses methods File#chown and File#chmod in removing directories.</p>
</li><li>
<p>The owner of the target directory should be either the current process or the super user (root).</p>
</li></ul>

<p>WARNING: You must ensure that <strong>ALL</strong> parent directories cannot be moved by other untrusted users.  For example, parent directories should not be owned by untrusted users, and should not be world writable except when the sticky bit is set.</p>

<p>For details of this security vulnerability, see Perl cases:</p>
<ul><li>
<p><a href="https://cve.mitre.org/cgi-bin/cvename.cgi?name=CAN-2005-0448">CVE-2005-0448</a>.</p>
</li><li>
<p><a href="https://cve.mitre.org/cgi-bin/cvename.cgi?name=CAN-2004-0452">CVE-2004-0452</a>.</p>
</li></ul>

    </section>

      <section id="5Buntitled-5D" class="documentation-section">


      <section class="constants-list">
      <header>
      <h3>Constants</h3>
      </header>
      <dl>
          <dt id="VERSION">VERSION
          <dd>
        </dl>
        </section>



                <section id="public-class-5Buntitled-5D-method-details" class="method-section">
                <header>
                <h3>Public Class Methods</h3>
                </header>

                  <div id="method-c-cd" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">cd</span><span
                                class="method-args">(dir, verbose: nil) { |dir| ... }</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Changes the working directory to the given <code>dir</code>, which should be <a href="FileUtils.html#module-FileUtils-label-Path+Arguments">interpretable as a path</a>:</p>

<p>With no block given, changes the current directory to the directory at <code>dir</code>; returns zero:</p>

<pre class="ruby"><span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">pwd</span> <span class="ruby-comment"># =&gt; &quot;/rdoc/fileutils&quot;</span>
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">cd</span>(<span class="ruby-string">&#39;..&#39;</span>)
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">pwd</span> <span class="ruby-comment"># =&gt; &quot;/rdoc&quot;</span>
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">cd</span>(<span class="ruby-string">&#39;fileutils&#39;</span>)
</pre>

<p>With a block given, changes the current directory to the directory at <code>dir</code>, calls the block with argument <code>dir</code>, and restores the original current directory; returns the block’s value:</p>

<pre class="ruby"><span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">pwd</span>                                     <span class="ruby-comment"># =&gt; &quot;/rdoc/fileutils&quot;</span>
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">cd</span>(<span class="ruby-string">&#39;..&#39;</span>) { <span class="ruby-operator">|</span><span class="ruby-identifier">arg</span><span class="ruby-operator">|</span> [<span class="ruby-identifier">arg</span>, <span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">pwd</span>] } <span class="ruby-comment"># =&gt; [&quot;..&quot;, &quot;/rdoc&quot;]</span>
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">pwd</span>                                     <span class="ruby-comment"># =&gt; &quot;/rdoc/fileutils&quot;</span>
</pre>

<p>Keyword arguments:</p>
<ul><li>
<p><code>verbose: true</code> - prints an equivalent command:</p>

<pre class="ruby"><span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">cd</span>(<span class="ruby-string">&#39;..&#39;</span>)
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">cd</span>(<span class="ruby-string">&#39;fileutils&#39;</span>)
</pre>

<p>Output:</p>

<pre>cd ..
cd fileutils</pre>
</li></ul>

<p>Related: <a href="FileUtils.html#method-c-pwd"><code>FileUtils.pwd</code></a>.</p>

                              <div class="method-source-code" id="cd-source">
            <pre><span class="ruby-comment"># File fileutils.rb, line 238</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">cd</span>(<span class="ruby-identifier">dir</span>, <span class="ruby-value">verbose:</span> <span class="ruby-keyword">nil</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>) <span class="ruby-comment"># :yield: dir</span>
  <span class="ruby-identifier">fu_output_message</span> <span class="ruby-node">&quot;cd #{dir}&quot;</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">verbose</span>
  <span class="ruby-identifier">result</span> = <span class="ruby-constant">Dir</span>.<span class="ruby-identifier">chdir</span>(<span class="ruby-identifier">dir</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
  <span class="ruby-identifier">fu_output_message</span> <span class="ruby-string">&#39;cd -&#39;</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">verbose</span> <span class="ruby-keyword">and</span> <span class="ruby-identifier">block</span>
  <span class="ruby-identifier">result</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>

                            <div class="aliases">
                              Also aliased as: <a href="FileUtils.html#method-i-chdir">chdir</a>
                            </div>

                          </div>

                  <div id="method-c-chdir" class="method-detail method-alias">
                            <div class="method-heading">
                              <span class="method-name">chdir</span><span
                                class="method-args">(dir, verbose: nil)</span>
                            </div>

                            <div class="method-description">
                              

                            </div>


                            <div class="aliases">
                              Alias for: <a href="FileUtils.html#method-i-cd">cd</a>
                            </div>
                          </div>

                  <div id="method-c-chmod" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">chmod</span><span
                                class="method-args">(mode, list, noop: nil, verbose: nil)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Changes permissions on the entries at the paths given in <code>list</code> (a single path or an array of paths) to the permissions given by <code>mode</code>; returns <code>list</code> if it is an array, <code>[list]</code> otherwise:</p>
<ul><li>
<p>Modifies each entry that is a regular file using File.chmod.</p>
</li><li>
<p>Modifies each entry that is a symbolic link using File.lchmod.</p>
</li></ul>

<p>Argument <code>list</code> or its elements should be <a href="FileUtils.html#module-FileUtils-label-Path+Arguments">interpretable as paths</a>.</p>

<p>Argument <code>mode</code> may be either an integer or a string:</p>
<ul><li>
<p>Integer <code>mode</code>: represents the permission bits to be set:</p>

<pre class="ruby"><span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">chmod</span>(<span class="ruby-value">0755</span>, <span class="ruby-string">&#39;src0.txt&#39;</span>)
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">chmod</span>(<span class="ruby-value">0644</span>, [<span class="ruby-string">&#39;src0.txt&#39;</span>, <span class="ruby-string">&#39;src0.dat&#39;</span>])
</pre>
</li><li>
<p>String <code>mode</code>: represents the permissions to be set:</p>

<p>The string is of the form <code>[targets][[operator][perms[,perms]]</code>, where:</p>
<ul><li>
<p><code>targets</code> may be any combination of these letters:</p>
<ul><li>
<p><code>&#39;u&#39;</code>: permissions apply to the file’s owner.</p>
</li><li>
<p><code>&#39;g&#39;</code>: permissions apply to users in the file’s group.</p>
</li><li>
<p><code>&#39;o&#39;</code>: permissions apply to other users not in the file’s group.</p>
</li><li>
<p><code>&#39;a&#39;</code> (the default): permissions apply to all users.</p>
</li></ul>
</li><li>
<p><code>operator</code> may be one of these letters:</p>
<ul><li>
<p><code>&#39;+&#39;</code>: adds permissions.</p>
</li><li>
<p><code>&#39;-&#39;</code>: removes permissions.</p>
</li><li>
<p><code>&#39;=&#39;</code>: sets (replaces) permissions.</p>
</li></ul>
</li><li>
<p><code>perms</code> (may be repeated, with separating commas) may be any combination of these letters:</p>
<ul><li>
<p><code>&#39;r&#39;</code>: Read.</p>
</li><li>
<p><code>&#39;w&#39;</code>: Write.</p>
</li><li>
<p><code>&#39;x&#39;</code>: Execute (search, for a directory).</p>
</li><li>
<p><code>&#39;X&#39;</code>: Search (for a directories only; must be used with <code>&#39;+&#39;</code>)</p>
</li><li>
<p><code>&#39;s&#39;</code>: Uid or gid.</p>
</li><li>
<p><code>&#39;t&#39;</code>: Sticky bit.</p>
</li></ul>
</li></ul>

<p>Examples:</p>

<pre class="ruby"><span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">chmod</span>(<span class="ruby-string">&#39;u=wrx,go=rx&#39;</span>, <span class="ruby-string">&#39;src1.txt&#39;</span>)
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">chmod</span>(<span class="ruby-string">&#39;u=wrx,go=rx&#39;</span>, <span class="ruby-string">&#39;/usr/bin/ruby&#39;</span>)
</pre>
</li></ul>

<p>Keyword arguments:</p>
<ul><li>
<p><code>noop: true</code> - does not change permissions; returns <code>nil</code>.</p>
</li><li>
<p><code>verbose: true</code> - prints an equivalent command:</p>

<pre class="ruby"><span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">chmod</span>(<span class="ruby-value">0755</span>, <span class="ruby-string">&#39;src0.txt&#39;</span>, <span class="ruby-value">noop:</span> <span class="ruby-keyword">true</span>, <span class="ruby-value">verbose:</span> <span class="ruby-keyword">true</span>)
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">chmod</span>(<span class="ruby-value">0644</span>, [<span class="ruby-string">&#39;src0.txt&#39;</span>, <span class="ruby-string">&#39;src0.dat&#39;</span>], <span class="ruby-value">noop:</span> <span class="ruby-keyword">true</span>, <span class="ruby-value">verbose:</span> <span class="ruby-keyword">true</span>)
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">chmod</span>(<span class="ruby-string">&#39;u=wrx,go=rx&#39;</span>, <span class="ruby-string">&#39;src1.txt&#39;</span>, <span class="ruby-value">noop:</span> <span class="ruby-keyword">true</span>, <span class="ruby-value">verbose:</span> <span class="ruby-keyword">true</span>)
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">chmod</span>(<span class="ruby-string">&#39;u=wrx,go=rx&#39;</span>, <span class="ruby-string">&#39;/usr/bin/ruby&#39;</span>, <span class="ruby-value">noop:</span> <span class="ruby-keyword">true</span>, <span class="ruby-value">verbose:</span> <span class="ruby-keyword">true</span>)
</pre>

<p>Output:</p>

<pre>chmod 755 src0.txt
chmod 644 src0.txt src0.dat
chmod u=wrx,go=rx src1.txt
chmod u=wrx,go=rx /usr/bin/ruby</pre>
</li></ul>

<p>Related: <a href="FileUtils.html#method-c-chmod_R"><code>FileUtils.chmod_R</code></a>.</p>

                              <div class="method-source-code" id="chmod-source">
            <pre><span class="ruby-comment"># File fileutils.rb, line 1803</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">chmod</span>(<span class="ruby-identifier">mode</span>, <span class="ruby-identifier">list</span>, <span class="ruby-value">noop:</span> <span class="ruby-keyword">nil</span>, <span class="ruby-value">verbose:</span> <span class="ruby-keyword">nil</span>)
  <span class="ruby-identifier">list</span> = <span class="ruby-identifier">fu_list</span>(<span class="ruby-identifier">list</span>)
  <span class="ruby-identifier">fu_output_message</span> <span class="ruby-identifier">sprintf</span>(<span class="ruby-string">&#39;chmod %s %s&#39;</span>, <span class="ruby-identifier">mode_to_s</span>(<span class="ruby-identifier">mode</span>), <span class="ruby-identifier">list</span>.<span class="ruby-identifier">join</span>(<span class="ruby-string">&#39; &#39;</span>)) <span class="ruby-keyword">if</span> <span class="ruby-identifier">verbose</span>
  <span class="ruby-keyword">return</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">noop</span>
  <span class="ruby-identifier">list</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">path</span><span class="ruby-operator">|</span>
    <span class="ruby-constant">Entry_</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">path</span>).<span class="ruby-identifier">chmod</span>(<span class="ruby-identifier">fu_mode</span>(<span class="ruby-identifier">mode</span>, <span class="ruby-identifier">path</span>))
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-chmod_R" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">chmod_R</span><span
                                class="method-args">(mode, list, noop: nil, verbose: nil, force: nil)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Like <a href="FileUtils.html#method-c-chmod"><code>FileUtils.chmod</code></a>, but changes permissions recursively.</p>

                              <div class="method-source-code" id="chmod_R-source">
            <pre><span class="ruby-comment"># File fileutils.rb, line 1815</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">chmod_R</span>(<span class="ruby-identifier">mode</span>, <span class="ruby-identifier">list</span>, <span class="ruby-value">noop:</span> <span class="ruby-keyword">nil</span>, <span class="ruby-value">verbose:</span> <span class="ruby-keyword">nil</span>, <span class="ruby-value">force:</span> <span class="ruby-keyword">nil</span>)
  <span class="ruby-identifier">list</span> = <span class="ruby-identifier">fu_list</span>(<span class="ruby-identifier">list</span>)
  <span class="ruby-identifier">fu_output_message</span> <span class="ruby-identifier">sprintf</span>(<span class="ruby-string">&#39;chmod -R%s %s %s&#39;</span>,
                            (<span class="ruby-identifier">force</span> <span class="ruby-operator">?</span> <span class="ruby-string">&#39;f&#39;</span> <span class="ruby-operator">:</span> <span class="ruby-string">&#39;&#39;</span>),
                            <span class="ruby-identifier">mode_to_s</span>(<span class="ruby-identifier">mode</span>), <span class="ruby-identifier">list</span>.<span class="ruby-identifier">join</span>(<span class="ruby-string">&#39; &#39;</span>)) <span class="ruby-keyword">if</span> <span class="ruby-identifier">verbose</span>
  <span class="ruby-keyword">return</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">noop</span>
  <span class="ruby-identifier">list</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">root</span><span class="ruby-operator">|</span>
    <span class="ruby-constant">Entry_</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">root</span>).<span class="ruby-identifier">traverse</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">ent</span><span class="ruby-operator">|</span>
      <span class="ruby-keyword">begin</span>
        <span class="ruby-identifier">ent</span>.<span class="ruby-identifier">chmod</span>(<span class="ruby-identifier">fu_mode</span>(<span class="ruby-identifier">mode</span>, <span class="ruby-identifier">ent</span>.<span class="ruby-identifier">path</span>))
      <span class="ruby-keyword">rescue</span>
        <span class="ruby-identifier">raise</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">force</span>
      <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-chown" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">chown</span><span
                                class="method-args">(user, group, list, noop: nil, verbose: nil)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Changes the owner and group on the entries at the paths given in <code>list</code> (a single path or an array of paths) to the given <code>user</code> and <code>group</code>; returns <code>list</code> if it is an array, <code>[list]</code> otherwise:</p>
<ul><li>
<p>Modifies each entry that is a regular file using File.chown.</p>
</li><li>
<p>Modifies each entry that is a symbolic link using File.lchown.</p>
</li></ul>

<p>Argument <code>list</code> or its elements should be <a href="FileUtils.html#module-FileUtils-label-Path+Arguments">interpretable as paths</a>.</p>

<p>User and group:</p>
<ul><li>
<p>Argument <code>user</code> may be a user name or a user id; if <code>nil</code> or <code>-1</code>, the user is not changed.</p>
</li><li>
<p>Argument <code>group</code> may be a group name or a group id; if <code>nil</code> or <code>-1</code>, the group is not changed.</p>
</li><li>
<p>The user must be a member of the group.</p>
</li></ul>

<p>Examples:</p>

<pre class="ruby"><span class="ruby-comment"># One path.</span>
<span class="ruby-comment"># User and group as string names.</span>
<span class="ruby-constant">File</span>.<span class="ruby-identifier">stat</span>(<span class="ruby-string">&#39;src0.txt&#39;</span>).<span class="ruby-identifier">uid</span> <span class="ruby-comment"># =&gt; 1004</span>
<span class="ruby-constant">File</span>.<span class="ruby-identifier">stat</span>(<span class="ruby-string">&#39;src0.txt&#39;</span>).<span class="ruby-identifier">gid</span> <span class="ruby-comment"># =&gt; 1004</span>
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">chown</span>(<span class="ruby-string">&#39;user2&#39;</span>, <span class="ruby-string">&#39;group1&#39;</span>, <span class="ruby-string">&#39;src0.txt&#39;</span>)
<span class="ruby-constant">File</span>.<span class="ruby-identifier">stat</span>(<span class="ruby-string">&#39;src0.txt&#39;</span>).<span class="ruby-identifier">uid</span> <span class="ruby-comment"># =&gt; 1006</span>
<span class="ruby-constant">File</span>.<span class="ruby-identifier">stat</span>(<span class="ruby-string">&#39;src0.txt&#39;</span>).<span class="ruby-identifier">gid</span> <span class="ruby-comment"># =&gt; 1005</span>

<span class="ruby-comment"># User and group as uid and gid.</span>
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">chown</span>(<span class="ruby-value">1004</span>, <span class="ruby-value">1004</span>, <span class="ruby-string">&#39;src0.txt&#39;</span>)
<span class="ruby-constant">File</span>.<span class="ruby-identifier">stat</span>(<span class="ruby-string">&#39;src0.txt&#39;</span>).<span class="ruby-identifier">uid</span> <span class="ruby-comment"># =&gt; 1004</span>
<span class="ruby-constant">File</span>.<span class="ruby-identifier">stat</span>(<span class="ruby-string">&#39;src0.txt&#39;</span>).<span class="ruby-identifier">gid</span> <span class="ruby-comment"># =&gt; 1004</span>

<span class="ruby-comment"># Array of paths.</span>
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">chown</span>(<span class="ruby-value">1006</span>, <span class="ruby-value">1005</span>, [<span class="ruby-string">&#39;src0.txt&#39;</span>, <span class="ruby-string">&#39;src0.dat&#39;</span>])

<span class="ruby-comment"># Directory (not recursive).</span>
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">chown</span>(<span class="ruby-string">&#39;user2&#39;</span>, <span class="ruby-string">&#39;group1&#39;</span>, <span class="ruby-string">&#39;.&#39;</span>)
</pre>

<p>Keyword arguments:</p>
<ul><li>
<p><code>noop: true</code> - does not change permissions; returns <code>nil</code>.</p>
</li><li>
<p><code>verbose: true</code> - prints an equivalent command:</p>

<pre class="ruby"><span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">chown</span>(<span class="ruby-string">&#39;user2&#39;</span>, <span class="ruby-string">&#39;group1&#39;</span>, <span class="ruby-string">&#39;src0.txt&#39;</span>, <span class="ruby-value">noop:</span> <span class="ruby-keyword">true</span>, <span class="ruby-value">verbose:</span> <span class="ruby-keyword">true</span>)
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">chown</span>(<span class="ruby-value">1004</span>, <span class="ruby-value">1004</span>, <span class="ruby-string">&#39;src0.txt&#39;</span>, <span class="ruby-value">noop:</span> <span class="ruby-keyword">true</span>, <span class="ruby-value">verbose:</span> <span class="ruby-keyword">true</span>)
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">chown</span>(<span class="ruby-value">1006</span>, <span class="ruby-value">1005</span>, [<span class="ruby-string">&#39;src0.txt&#39;</span>, <span class="ruby-string">&#39;src0.dat&#39;</span>], <span class="ruby-value">noop:</span> <span class="ruby-keyword">true</span>, <span class="ruby-value">verbose:</span> <span class="ruby-keyword">true</span>)
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">chown</span>(<span class="ruby-string">&#39;user2&#39;</span>, <span class="ruby-string">&#39;group1&#39;</span>, <span class="ruby-identifier">path</span>, <span class="ruby-value">noop:</span> <span class="ruby-keyword">true</span>, <span class="ruby-value">verbose:</span> <span class="ruby-keyword">true</span>)
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">chown</span>(<span class="ruby-string">&#39;user2&#39;</span>, <span class="ruby-string">&#39;group1&#39;</span>, <span class="ruby-string">&#39;.&#39;</span>, <span class="ruby-value">noop:</span> <span class="ruby-keyword">true</span>, <span class="ruby-value">verbose:</span> <span class="ruby-keyword">true</span>)
</pre>

<p>Output:</p>

<pre>chown user2:group1 src0.txt
chown 1004:1004 src0.txt
chown 1006:1005 src0.txt src0.dat
chown user2:group1 src0.txt
chown user2:group1 .</pre>
</li></ul>

<p>Related: <a href="FileUtils.html#method-c-chown_R"><code>FileUtils.chown_R</code></a>.</p>

                              <div class="method-source-code" id="chown-source">
            <pre><span class="ruby-comment"># File fileutils.rb, line 1896</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">chown</span>(<span class="ruby-identifier">user</span>, <span class="ruby-identifier">group</span>, <span class="ruby-identifier">list</span>, <span class="ruby-value">noop:</span> <span class="ruby-keyword">nil</span>, <span class="ruby-value">verbose:</span> <span class="ruby-keyword">nil</span>)
  <span class="ruby-identifier">list</span> = <span class="ruby-identifier">fu_list</span>(<span class="ruby-identifier">list</span>)
  <span class="ruby-identifier">fu_output_message</span> <span class="ruby-identifier">sprintf</span>(<span class="ruby-string">&#39;chown %s %s&#39;</span>,
                            (<span class="ruby-identifier">group</span> <span class="ruby-operator">?</span> <span class="ruby-node">&quot;#{user}:#{group}&quot;</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">user</span> <span class="ruby-operator">||</span> <span class="ruby-string">&#39;:&#39;</span>),
                            <span class="ruby-identifier">list</span>.<span class="ruby-identifier">join</span>(<span class="ruby-string">&#39; &#39;</span>)) <span class="ruby-keyword">if</span> <span class="ruby-identifier">verbose</span>
  <span class="ruby-keyword">return</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">noop</span>
  <span class="ruby-identifier">uid</span> = <span class="ruby-identifier">fu_get_uid</span>(<span class="ruby-identifier">user</span>)
  <span class="ruby-identifier">gid</span> = <span class="ruby-identifier">fu_get_gid</span>(<span class="ruby-identifier">group</span>)
  <span class="ruby-identifier">list</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">path</span><span class="ruby-operator">|</span>
    <span class="ruby-constant">Entry_</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">path</span>).<span class="ruby-identifier">chown</span> <span class="ruby-identifier">uid</span>, <span class="ruby-identifier">gid</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-chown_R" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">chown_R</span><span
                                class="method-args">(user, group, list, noop: nil, verbose: nil, force: nil)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Like <a href="FileUtils.html#method-c-chown"><code>FileUtils.chown</code></a>, but changes owner and group recursively.</p>

                              <div class="method-source-code" id="chown_R-source">
            <pre><span class="ruby-comment"># File fileutils.rb, line 1912</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">chown_R</span>(<span class="ruby-identifier">user</span>, <span class="ruby-identifier">group</span>, <span class="ruby-identifier">list</span>, <span class="ruby-value">noop:</span> <span class="ruby-keyword">nil</span>, <span class="ruby-value">verbose:</span> <span class="ruby-keyword">nil</span>, <span class="ruby-value">force:</span> <span class="ruby-keyword">nil</span>)
  <span class="ruby-identifier">list</span> = <span class="ruby-identifier">fu_list</span>(<span class="ruby-identifier">list</span>)
  <span class="ruby-identifier">fu_output_message</span> <span class="ruby-identifier">sprintf</span>(<span class="ruby-string">&#39;chown -R%s %s %s&#39;</span>,
                            (<span class="ruby-identifier">force</span> <span class="ruby-operator">?</span> <span class="ruby-string">&#39;f&#39;</span> <span class="ruby-operator">:</span> <span class="ruby-string">&#39;&#39;</span>),
                            (<span class="ruby-identifier">group</span> <span class="ruby-operator">?</span> <span class="ruby-node">&quot;#{user}:#{group}&quot;</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">user</span> <span class="ruby-operator">||</span> <span class="ruby-string">&#39;:&#39;</span>),
                            <span class="ruby-identifier">list</span>.<span class="ruby-identifier">join</span>(<span class="ruby-string">&#39; &#39;</span>)) <span class="ruby-keyword">if</span> <span class="ruby-identifier">verbose</span>
  <span class="ruby-keyword">return</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">noop</span>
  <span class="ruby-identifier">uid</span> = <span class="ruby-identifier">fu_get_uid</span>(<span class="ruby-identifier">user</span>)
  <span class="ruby-identifier">gid</span> = <span class="ruby-identifier">fu_get_gid</span>(<span class="ruby-identifier">group</span>)
  <span class="ruby-identifier">list</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">root</span><span class="ruby-operator">|</span>
    <span class="ruby-constant">Entry_</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">root</span>).<span class="ruby-identifier">traverse</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">ent</span><span class="ruby-operator">|</span>
      <span class="ruby-keyword">begin</span>
        <span class="ruby-identifier">ent</span>.<span class="ruby-identifier">chown</span> <span class="ruby-identifier">uid</span>, <span class="ruby-identifier">gid</span>
      <span class="ruby-keyword">rescue</span>
        <span class="ruby-identifier">raise</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">force</span>
      <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-cmp" class="method-detail method-alias">
                            <div class="method-heading">
                              <span class="method-name">cmp</span><span
                                class="method-args">(a, b)</span>
                            </div>

                            <div class="method-description">
                              

                            </div>


                            <div class="aliases">
                              Alias for: <a href="FileUtils.html#method-i-compare_file">compare_file</a>
                            </div>
                          </div>

                  <div id="method-c-collect_method" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">collect_method</span><span
                                class="method-args">(opt)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns an array of the string method names of the methods that accept the given keyword option <code>opt</code>; the argument must be a symbol:</p>

<pre class="ruby"><span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">collect_method</span>(<span class="ruby-value">:preserve</span>) <span class="ruby-comment"># =&gt; [&quot;cp&quot;, &quot;copy&quot;, &quot;cp_r&quot;, &quot;install&quot;]</span>
</pre>

                              <div class="method-source-code" id="collect_method-source">
            <pre><span class="ruby-comment"># File fileutils.rb, line 2609</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">collect_method</span>(<span class="ruby-identifier">opt</span>)
  <span class="ruby-constant">OPT_TABLE</span>.<span class="ruby-identifier">keys</span>.<span class="ruby-identifier">select</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">m</span><span class="ruby-operator">|</span> <span class="ruby-constant">OPT_TABLE</span>[<span class="ruby-identifier">m</span>].<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">opt</span>) }
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-commands" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">commands</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns an array of the string names of FileUtils methods that accept one or more keyword arguments:</p>

<pre class="ruby"><span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">commands</span>.<span class="ruby-identifier">sort</span>.<span class="ruby-identifier">take</span>(<span class="ruby-value">3</span>) <span class="ruby-comment"># =&gt; [&quot;cd&quot;, &quot;chdir&quot;, &quot;chmod&quot;]</span>
</pre>

                              <div class="method-source-code" id="commands-source">
            <pre><span class="ruby-comment"># File fileutils.rb, line 2570</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">commands</span>
  <span class="ruby-constant">OPT_TABLE</span>.<span class="ruby-identifier">keys</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-compare_file" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">compare_file</span><span
                                class="method-args">(a, b)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns <code>true</code> if the contents of files <code>a</code> and <code>b</code> are identical, <code>false</code> otherwise.</p>

<p>Arguments <code>a</code> and <code>b</code> should be <a href="FileUtils.html#module-FileUtils-label-Path+Arguments">interpretable as a path</a>.</p>

<p><a href="FileUtils.html#method-c-identical-3F"><code>FileUtils.identical?</code></a> and <a href="FileUtils.html#method-c-cmp"><code>FileUtils.cmp</code></a> are aliases for <a href="FileUtils.html#method-c-compare_file"><code>FileUtils.compare_file</code></a>.</p>

<p>Related: <a href="FileUtils.html#method-c-compare_stream"><code>FileUtils.compare_stream</code></a>.</p>

                              <div class="method-source-code" id="compare_file-source">
            <pre><span class="ruby-comment"># File fileutils.rb, line 1507</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">compare_file</span>(<span class="ruby-identifier">a</span>, <span class="ruby-identifier">b</span>)
  <span class="ruby-keyword">return</span> <span class="ruby-keyword">false</span> <span class="ruby-keyword">unless</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">size</span>(<span class="ruby-identifier">a</span>) <span class="ruby-operator">==</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">size</span>(<span class="ruby-identifier">b</span>)
  <span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-identifier">a</span>, <span class="ruby-string">&#39;rb&#39;</span>) {<span class="ruby-operator">|</span><span class="ruby-identifier">fa</span><span class="ruby-operator">|</span>
    <span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-identifier">b</span>, <span class="ruby-string">&#39;rb&#39;</span>) {<span class="ruby-operator">|</span><span class="ruby-identifier">fb</span><span class="ruby-operator">|</span>
      <span class="ruby-keyword">return</span> <span class="ruby-identifier">compare_stream</span>(<span class="ruby-identifier">fa</span>, <span class="ruby-identifier">fb</span>)
    }
  }
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>

                            <div class="aliases">
                              Also aliased as: <a href="FileUtils.html#method-i-identical-3F">identical?</a>, <a href="FileUtils.html#method-i-cmp">cmp</a>
                            </div>

                          </div>

                  <div id="method-c-compare_stream" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">compare_stream</span><span
                                class="method-args">(a, b)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns <code>true</code> if the contents of streams <code>a</code> and <code>b</code> are identical, <code>false</code> otherwise.</p>

<p>Arguments <code>a</code> and <code>b</code> should be <a href="FileUtils.html#module-FileUtils-label-Path+Arguments">interpretable as a path</a>.</p>

<p>Related: <a href="FileUtils.html#method-c-compare_file"><code>FileUtils.compare_file</code></a>.</p>

                              <div class="method-source-code" id="compare_stream-source">
            <pre><span class="ruby-comment"># File fileutils.rb, line 1530</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">compare_stream</span>(<span class="ruby-identifier">a</span>, <span class="ruby-identifier">b</span>)
  <span class="ruby-identifier">bsize</span> = <span class="ruby-identifier">fu_stream_blksize</span>(<span class="ruby-identifier">a</span>, <span class="ruby-identifier">b</span>)

  <span class="ruby-identifier">sa</span> = <span class="ruby-constant">String</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">capacity:</span> <span class="ruby-identifier">bsize</span>)
  <span class="ruby-identifier">sb</span> = <span class="ruby-constant">String</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">capacity:</span> <span class="ruby-identifier">bsize</span>)

  <span class="ruby-keyword">begin</span>
    <span class="ruby-identifier">a</span>.<span class="ruby-identifier">read</span>(<span class="ruby-identifier">bsize</span>, <span class="ruby-identifier">sa</span>)
    <span class="ruby-identifier">b</span>.<span class="ruby-identifier">read</span>(<span class="ruby-identifier">bsize</span>, <span class="ruby-identifier">sb</span>)
    <span class="ruby-keyword">return</span> <span class="ruby-keyword">true</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">sa</span>.<span class="ruby-identifier">empty?</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">sb</span>.<span class="ruby-identifier">empty?</span>
  <span class="ruby-keyword">end</span> <span class="ruby-keyword">while</span> <span class="ruby-identifier">sa</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">sb</span>
  <span class="ruby-keyword">false</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-copy" class="method-detail method-alias">
                            <div class="method-heading">
                              <span class="method-name">copy</span><span
                                class="method-args">(src, dest, preserve: nil, noop: nil, verbose: nil)</span>
                            </div>

                            <div class="method-description">
                              

                            </div>


                            <div class="aliases">
                              Alias for: <a href="FileUtils.html#method-i-cp">cp</a>
                            </div>
                          </div>

                  <div id="method-c-copy_entry" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">copy_entry</span><span
                                class="method-args">(src, dest, preserve = false, dereference_root = false, remove_destination = false)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Recursively copies files from <code>src</code> to <code>dest</code>.</p>

<p>Arguments <code>src</code> and <code>dest</code> should be <a href="FileUtils.html#module-FileUtils-label-Path+Arguments">interpretable as paths</a>.</p>

<p>If <code>src</code> is the path to a file, copies <code>src</code> to <code>dest</code>:</p>

<pre class="ruby"><span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">touch</span>(<span class="ruby-string">&#39;src0.txt&#39;</span>)
<span class="ruby-constant">File</span>.<span class="ruby-identifier">exist?</span>(<span class="ruby-string">&#39;dest0.txt&#39;</span>) <span class="ruby-comment"># =&gt; false</span>
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">copy_entry</span>(<span class="ruby-string">&#39;src0.txt&#39;</span>, <span class="ruby-string">&#39;dest0.txt&#39;</span>)
<span class="ruby-constant">File</span>.<span class="ruby-identifier">file?</span>(<span class="ruby-string">&#39;dest0.txt&#39;</span>)  <span class="ruby-comment"># =&gt; true</span>
</pre>

<p>If <code>src</code> is a directory, recursively copies <code>src</code> to <code>dest</code>:</p>

<pre class="ruby"><span class="ruby-identifier">tree</span>(<span class="ruby-string">&#39;src1&#39;</span>)
<span class="ruby-comment"># =&gt; src1</span>
<span class="ruby-comment">#    |-- dir0</span>
<span class="ruby-comment">#    |   |-- src0.txt</span>
<span class="ruby-comment">#    |   `-- src1.txt</span>
<span class="ruby-comment">#    `-- dir1</span>
<span class="ruby-comment">#        |-- src2.txt</span>
<span class="ruby-comment">#        `-- src3.txt</span>
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">copy_entry</span>(<span class="ruby-string">&#39;src1&#39;</span>, <span class="ruby-string">&#39;dest1&#39;</span>)
<span class="ruby-identifier">tree</span>(<span class="ruby-string">&#39;dest1&#39;</span>)
<span class="ruby-comment"># =&gt; dest1</span>
<span class="ruby-comment">#    |-- dir0</span>
<span class="ruby-comment">#    |   |-- src0.txt</span>
<span class="ruby-comment">#    |   `-- src1.txt</span>
<span class="ruby-comment">#    `-- dir1</span>
<span class="ruby-comment">#        |-- src2.txt</span>
<span class="ruby-comment">#        `-- src3.txt</span>
</pre>

<p>The recursive copying preserves file types for regular files, directories, and symbolic links; other file types (FIFO streams, device files, etc.) are not supported.</p>

<p>Keyword arguments:</p>
<ul><li>
<p><code>dereference_root: true</code> - if <code>src</code> is a symbolic link, follows the link.</p>
</li><li>
<p><code>preserve: true</code> - preserves file times.</p>
</li><li>
<p><code>remove_destination: true</code> - removes <code>dest</code> before copying files.</p>
</li></ul>

<p>Related: <a href="FileUtils.html#module-FileUtils-label-Copying">methods for copying</a>.</p>

                              <div class="method-source-code" id="copy_entry-source">
            <pre><span class="ruby-comment"># File fileutils.rb, line 1040</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">copy_entry</span>(<span class="ruby-identifier">src</span>, <span class="ruby-identifier">dest</span>, <span class="ruby-identifier">preserve</span> = <span class="ruby-keyword">false</span>, <span class="ruby-identifier">dereference_root</span> = <span class="ruby-keyword">false</span>, <span class="ruby-identifier">remove_destination</span> = <span class="ruby-keyword">false</span>)
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">dereference_root</span>
    <span class="ruby-identifier">src</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">realpath</span>(<span class="ruby-identifier">src</span>)
  <span class="ruby-keyword">end</span>

  <span class="ruby-constant">Entry_</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">src</span>, <span class="ruby-keyword">nil</span>, <span class="ruby-keyword">false</span>).<span class="ruby-identifier">wrap_traverse</span>(<span class="ruby-identifier">proc</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">ent</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">destent</span> = <span class="ruby-constant">Entry_</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">dest</span>, <span class="ruby-identifier">ent</span>.<span class="ruby-identifier">rel</span>, <span class="ruby-keyword">false</span>)
    <span class="ruby-constant">File</span>.<span class="ruby-identifier">unlink</span> <span class="ruby-identifier">destent</span>.<span class="ruby-identifier">path</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">remove_destination</span> <span class="ruby-operator">&amp;&amp;</span> (<span class="ruby-constant">File</span>.<span class="ruby-identifier">file?</span>(<span class="ruby-identifier">destent</span>.<span class="ruby-identifier">path</span>) <span class="ruby-operator">||</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">symlink?</span>(<span class="ruby-identifier">destent</span>.<span class="ruby-identifier">path</span>))
    <span class="ruby-identifier">ent</span>.<span class="ruby-identifier">copy</span> <span class="ruby-identifier">destent</span>.<span class="ruby-identifier">path</span>
  <span class="ruby-keyword">end</span>, <span class="ruby-identifier">proc</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">ent</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">destent</span> = <span class="ruby-constant">Entry_</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">dest</span>, <span class="ruby-identifier">ent</span>.<span class="ruby-identifier">rel</span>, <span class="ruby-keyword">false</span>)
    <span class="ruby-identifier">ent</span>.<span class="ruby-identifier">copy_metadata</span> <span class="ruby-identifier">destent</span>.<span class="ruby-identifier">path</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">preserve</span>
  <span class="ruby-keyword">end</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-copy_file" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">copy_file</span><span
                                class="method-args">(src, dest, preserve = false, dereference = true)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Copies file from <code>src</code> to <code>dest</code>, which should not be directories.</p>

<p>Arguments <code>src</code> and <code>dest</code> should be <a href="FileUtils.html#module-FileUtils-label-Path+Arguments">interpretable as paths</a>.</p>

<p>Examples:</p>

<pre class="ruby"><span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">touch</span>(<span class="ruby-string">&#39;src0.txt&#39;</span>)
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">copy_file</span>(<span class="ruby-string">&#39;src0.txt&#39;</span>, <span class="ruby-string">&#39;dest0.txt&#39;</span>)
<span class="ruby-constant">File</span>.<span class="ruby-identifier">file?</span>(<span class="ruby-string">&#39;dest0.txt&#39;</span>) <span class="ruby-comment"># =&gt; true</span>
</pre>

<p>Keyword arguments:</p>
<ul><li>
<p><code>dereference: false</code> - if <code>src</code> is a symbolic link, does not follow the link.</p>
</li><li>
<p><code>preserve: true</code> - preserves file times.</p>
</li><li>
<p><code>remove_destination: true</code> - removes <code>dest</code> before copying files.</p>
</li></ul>

<p>Related: <a href="FileUtils.html#module-FileUtils-label-Copying">methods for copying</a>.</p>

                              <div class="method-source-code" id="copy_file-source">
            <pre><span class="ruby-comment"># File fileutils.rb, line 1076</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">copy_file</span>(<span class="ruby-identifier">src</span>, <span class="ruby-identifier">dest</span>, <span class="ruby-identifier">preserve</span> = <span class="ruby-keyword">false</span>, <span class="ruby-identifier">dereference</span> = <span class="ruby-keyword">true</span>)
  <span class="ruby-identifier">ent</span> = <span class="ruby-constant">Entry_</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">src</span>, <span class="ruby-keyword">nil</span>, <span class="ruby-identifier">dereference</span>)
  <span class="ruby-identifier">ent</span>.<span class="ruby-identifier">copy_file</span> <span class="ruby-identifier">dest</span>
  <span class="ruby-identifier">ent</span>.<span class="ruby-identifier">copy_metadata</span> <span class="ruby-identifier">dest</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">preserve</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-copy_stream" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">copy_stream</span><span
                                class="method-args">(src, dest)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Copies IO stream <code>src</code> to IO stream <code>dest</code> via IO.copy_stream.</p>

<p>Related: <a href="FileUtils.html#module-FileUtils-label-Copying">methods for copying</a>.</p>

                              <div class="method-source-code" id="copy_stream-source">
            <pre><span class="ruby-comment"># File fileutils.rb, line 1088</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">copy_stream</span>(<span class="ruby-identifier">src</span>, <span class="ruby-identifier">dest</span>)
  <span class="ruby-constant">IO</span>.<span class="ruby-identifier">copy_stream</span>(<span class="ruby-identifier">src</span>, <span class="ruby-identifier">dest</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-cp" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">cp</span><span
                                class="method-args">(src, dest, preserve: nil, noop: nil, verbose: nil)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Copies files.</p>

<p>Arguments <code>src</code> (a single path or an array of paths) and <code>dest</code> (a single path) should be <a href="FileUtils.html#module-FileUtils-label-Path+Arguments">interpretable as paths</a>.</p>

<p>If <code>src</code> is the path to a file and <code>dest</code> is not the path to a directory, copies <code>src</code> to <code>dest</code>:</p>

<pre class="ruby"><span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">touch</span>(<span class="ruby-string">&#39;src0.txt&#39;</span>)
<span class="ruby-constant">File</span>.<span class="ruby-identifier">exist?</span>(<span class="ruby-string">&#39;dest0.txt&#39;</span>) <span class="ruby-comment"># =&gt; false</span>
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">cp</span>(<span class="ruby-string">&#39;src0.txt&#39;</span>, <span class="ruby-string">&#39;dest0.txt&#39;</span>)
<span class="ruby-constant">File</span>.<span class="ruby-identifier">file?</span>(<span class="ruby-string">&#39;dest0.txt&#39;</span>)  <span class="ruby-comment"># =&gt; true</span>
</pre>

<p>If <code>src</code> is the path to a file and <code>dest</code> is the path to a directory, copies <code>src</code> to <code>dest/src</code>:</p>

<pre class="ruby"><span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">touch</span>(<span class="ruby-string">&#39;src1.txt&#39;</span>)
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">mkdir</span>(<span class="ruby-string">&#39;dest1&#39;</span>)
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">cp</span>(<span class="ruby-string">&#39;src1.txt&#39;</span>, <span class="ruby-string">&#39;dest1&#39;</span>)
<span class="ruby-constant">File</span>.<span class="ruby-identifier">file?</span>(<span class="ruby-string">&#39;dest1/src1.txt&#39;</span>) <span class="ruby-comment"># =&gt; true</span>
</pre>

<p>If <code>src</code> is an array of paths to files and <code>dest</code> is the path to a directory, copies from each <code>src</code> to <code>dest</code>:</p>

<pre class="ruby"><span class="ruby-identifier">src_file_paths</span> = [<span class="ruby-string">&#39;src2.txt&#39;</span>, <span class="ruby-string">&#39;src2.dat&#39;</span>]
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">touch</span>(<span class="ruby-identifier">src_file_paths</span>)
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">mkdir</span>(<span class="ruby-string">&#39;dest2&#39;</span>)
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">cp</span>(<span class="ruby-identifier">src_file_paths</span>, <span class="ruby-string">&#39;dest2&#39;</span>)
<span class="ruby-constant">File</span>.<span class="ruby-identifier">file?</span>(<span class="ruby-string">&#39;dest2/src2.txt&#39;</span>) <span class="ruby-comment"># =&gt; true</span>
<span class="ruby-constant">File</span>.<span class="ruby-identifier">file?</span>(<span class="ruby-string">&#39;dest2/src2.dat&#39;</span>) <span class="ruby-comment"># =&gt; true</span>
</pre>

<p>Keyword arguments:</p>
<ul><li>
<p><code>preserve: true</code> - preserves file times.</p>
</li><li>
<p><code>noop: true</code> - does not copy files.</p>
</li><li>
<p><code>verbose: true</code> - prints an equivalent command:</p>

<pre class="ruby"><span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">cp</span>(<span class="ruby-string">&#39;src0.txt&#39;</span>, <span class="ruby-string">&#39;dest0.txt&#39;</span>, <span class="ruby-value">noop:</span> <span class="ruby-keyword">true</span>, <span class="ruby-value">verbose:</span> <span class="ruby-keyword">true</span>)
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">cp</span>(<span class="ruby-string">&#39;src1.txt&#39;</span>, <span class="ruby-string">&#39;dest1&#39;</span>, <span class="ruby-value">noop:</span> <span class="ruby-keyword">true</span>, <span class="ruby-value">verbose:</span> <span class="ruby-keyword">true</span>)
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">cp</span>(<span class="ruby-identifier">src_file_paths</span>, <span class="ruby-string">&#39;dest2&#39;</span>, <span class="ruby-value">noop:</span> <span class="ruby-keyword">true</span>, <span class="ruby-value">verbose:</span> <span class="ruby-keyword">true</span>)
</pre>

<p>Output:</p>

<pre class="ruby"><span class="ruby-identifier">cp</span> <span class="ruby-identifier">src0</span>.<span class="ruby-identifier">txt</span> <span class="ruby-identifier">dest0</span>.<span class="ruby-identifier">txt</span>
<span class="ruby-identifier">cp</span> <span class="ruby-identifier">src1</span>.<span class="ruby-identifier">txt</span> <span class="ruby-identifier">dest1</span>
<span class="ruby-identifier">cp</span> <span class="ruby-identifier">src2</span>.<span class="ruby-identifier">txt</span> <span class="ruby-identifier">src2</span>.<span class="ruby-identifier">dat</span> <span class="ruby-identifier">dest2</span>
</pre>
</li></ul>

<p>Raises an exception if <code>src</code> is a directory.</p>

<p>Related: <a href="FileUtils.html#module-FileUtils-label-Copying">methods for copying</a>.</p>

                              <div class="method-source-code" id="cp-source">
            <pre><span class="ruby-comment"># File fileutils.rb, line 873</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">cp</span>(<span class="ruby-identifier">src</span>, <span class="ruby-identifier">dest</span>, <span class="ruby-value">preserve:</span> <span class="ruby-keyword">nil</span>, <span class="ruby-value">noop:</span> <span class="ruby-keyword">nil</span>, <span class="ruby-value">verbose:</span> <span class="ruby-keyword">nil</span>)
  <span class="ruby-identifier">fu_output_message</span> <span class="ruby-node">&quot;cp#{preserve ? &#39; -p&#39; : &#39;&#39;} #{[src,dest].flatten.join &#39; &#39;}&quot;</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">verbose</span>
  <span class="ruby-keyword">return</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">noop</span>
  <span class="ruby-identifier">fu_each_src_dest</span>(<span class="ruby-identifier">src</span>, <span class="ruby-identifier">dest</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">s</span>, <span class="ruby-identifier">d</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">copy_file</span> <span class="ruby-identifier">s</span>, <span class="ruby-identifier">d</span>, <span class="ruby-identifier">preserve</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>

                            <div class="aliases">
                              Also aliased as: <a href="FileUtils.html#method-i-copy">copy</a>
                            </div>

                          </div>

                  <div id="method-c-cp_lr" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">cp_lr</span><span
                                class="method-args">(src, dest, noop: nil, verbose: nil, dereference_root: true, remove_destination: false)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Creates <a href="https://en.wikipedia.org/wiki/Hard_link">hard links</a>.</p>

<p>Arguments <code>src</code> (a single path or an array of paths) and <code>dest</code> (a single path) should be <a href="FileUtils.html#module-FileUtils-label-Path+Arguments">interpretable as paths</a>.</p>

<p>If <code>src</code> is the path to a directory and <code>dest</code> does not exist, creates links <code>dest</code> and descendents pointing to <code>src</code> and its descendents:</p>

<pre class="ruby"><span class="ruby-identifier">tree</span>(<span class="ruby-string">&#39;src0&#39;</span>)
<span class="ruby-comment"># =&gt; src0</span>
<span class="ruby-comment">#    |-- sub0</span>
<span class="ruby-comment">#    |   |-- src0.txt</span>
<span class="ruby-comment">#    |   `-- src1.txt</span>
<span class="ruby-comment">#    `-- sub1</span>
<span class="ruby-comment">#        |-- src2.txt</span>
<span class="ruby-comment">#        `-- src3.txt</span>
<span class="ruby-constant">File</span>.<span class="ruby-identifier">exist?</span>(<span class="ruby-string">&#39;dest0&#39;</span>) <span class="ruby-comment"># =&gt; false</span>
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">cp_lr</span>(<span class="ruby-string">&#39;src0&#39;</span>, <span class="ruby-string">&#39;dest0&#39;</span>)
<span class="ruby-identifier">tree</span>(<span class="ruby-string">&#39;dest0&#39;</span>)
<span class="ruby-comment"># =&gt; dest0</span>
<span class="ruby-comment">#    |-- sub0</span>
<span class="ruby-comment">#    |   |-- src0.txt</span>
<span class="ruby-comment">#    |   `-- src1.txt</span>
<span class="ruby-comment">#    `-- sub1</span>
<span class="ruby-comment">#        |-- src2.txt</span>
<span class="ruby-comment">#        `-- src3.txt</span>
</pre>

<p>If <code>src</code> and <code>dest</code> are both paths to directories, creates links <code>dest/src</code> and descendents pointing to <code>src</code> and its descendents:</p>

<pre class="ruby"><span class="ruby-identifier">tree</span>(<span class="ruby-string">&#39;src1&#39;</span>)
<span class="ruby-comment"># =&gt; src1</span>
<span class="ruby-comment">#    |-- sub0</span>
<span class="ruby-comment">#    |   |-- src0.txt</span>
<span class="ruby-comment">#    |   `-- src1.txt</span>
<span class="ruby-comment">#    `-- sub1</span>
<span class="ruby-comment">#        |-- src2.txt</span>
<span class="ruby-comment">#        `-- src3.txt</span>
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">mkdir</span>(<span class="ruby-string">&#39;dest1&#39;</span>)
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">cp_lr</span>(<span class="ruby-string">&#39;src1&#39;</span>, <span class="ruby-string">&#39;dest1&#39;</span>)
<span class="ruby-identifier">tree</span>(<span class="ruby-string">&#39;dest1&#39;</span>)
<span class="ruby-comment"># =&gt; dest1</span>
<span class="ruby-comment">#    `-- src1</span>
<span class="ruby-comment">#        |-- sub0</span>
<span class="ruby-comment">#        |   |-- src0.txt</span>
<span class="ruby-comment">#        |   `-- src1.txt</span>
<span class="ruby-comment">#        `-- sub1</span>
<span class="ruby-comment">#            |-- src2.txt</span>
<span class="ruby-comment">#            `-- src3.txt</span>
</pre>

<p>If <code>src</code> is an array of paths to entries and <code>dest</code> is the path to a directory, for each path <code>filepath</code> in <code>src</code>, creates a link at <code>dest/filepath</code> pointing to that path:</p>

<pre class="ruby"><span class="ruby-identifier">tree</span>(<span class="ruby-string">&#39;src2&#39;</span>)
<span class="ruby-comment"># =&gt; src2</span>
<span class="ruby-comment">#    |-- sub0</span>
<span class="ruby-comment">#    |   |-- src0.txt</span>
<span class="ruby-comment">#    |   `-- src1.txt</span>
<span class="ruby-comment">#    `-- sub1</span>
<span class="ruby-comment">#        |-- src2.txt</span>
<span class="ruby-comment">#        `-- src3.txt</span>
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">mkdir</span>(<span class="ruby-string">&#39;dest2&#39;</span>)
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">cp_lr</span>([<span class="ruby-string">&#39;src2/sub0&#39;</span>, <span class="ruby-string">&#39;src2/sub1&#39;</span>], <span class="ruby-string">&#39;dest2&#39;</span>)
<span class="ruby-identifier">tree</span>(<span class="ruby-string">&#39;dest2&#39;</span>)
<span class="ruby-comment"># =&gt; dest2</span>
<span class="ruby-comment">#    |-- sub0</span>
<span class="ruby-comment">#    |   |-- src0.txt</span>
<span class="ruby-comment">#    |   `-- src1.txt</span>
<span class="ruby-comment">#    `-- sub1</span>
<span class="ruby-comment">#        |-- src2.txt</span>
<span class="ruby-comment">#        `-- src3.txt</span>
</pre>

<p>Keyword arguments:</p>
<ul><li>
<p><code>dereference_root: false</code> - if <code>src</code> is a symbolic link, does not dereference it.</p>
</li><li>
<p><code>noop: true</code> - does not create links.</p>
</li><li>
<p><code>remove_destination: true</code> - removes <code>dest</code> before creating links.</p>
</li><li>
<p><code>verbose: true</code> - prints an equivalent command:</p>

<pre class="ruby"><span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">cp_lr</span>(<span class="ruby-string">&#39;src0&#39;</span>, <span class="ruby-string">&#39;dest0&#39;</span>, <span class="ruby-value">noop:</span> <span class="ruby-keyword">true</span>, <span class="ruby-value">verbose:</span> <span class="ruby-keyword">true</span>)
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">cp_lr</span>(<span class="ruby-string">&#39;src1&#39;</span>, <span class="ruby-string">&#39;dest1&#39;</span>, <span class="ruby-value">noop:</span> <span class="ruby-keyword">true</span>, <span class="ruby-value">verbose:</span> <span class="ruby-keyword">true</span>)
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">cp_lr</span>([<span class="ruby-string">&#39;src2/sub0&#39;</span>, <span class="ruby-string">&#39;src2/sub1&#39;</span>], <span class="ruby-string">&#39;dest2&#39;</span>, <span class="ruby-value">noop:</span> <span class="ruby-keyword">true</span>, <span class="ruby-value">verbose:</span> <span class="ruby-keyword">true</span>)
</pre>

<p>Output:</p>

<pre>cp -lr src0 dest0
cp -lr src1 dest1
cp -lr src2/sub0 src2/sub1 dest2</pre>
</li></ul>

<p>Raises an exception if <code>dest</code> is the path to an existing file or directory and keyword argument <code>remove_destination: true</code> is not given.</p>

<p>Related: <a href="FileUtils.html#module-FileUtils-label-Copying">methods for copying</a>.</p>

                              <div class="method-source-code" id="cp_lr-source">
            <pre><span class="ruby-comment"># File fileutils.rb, line 627</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">cp_lr</span>(<span class="ruby-identifier">src</span>, <span class="ruby-identifier">dest</span>, <span class="ruby-value">noop:</span> <span class="ruby-keyword">nil</span>, <span class="ruby-value">verbose:</span> <span class="ruby-keyword">nil</span>,
          <span class="ruby-value">dereference_root:</span> <span class="ruby-keyword">true</span>, <span class="ruby-value">remove_destination:</span> <span class="ruby-keyword">false</span>)
  <span class="ruby-identifier">fu_output_message</span> <span class="ruby-node">&quot;cp -lr#{remove_destination ? &#39; --remove-destination&#39; : &#39;&#39;} #{[src,dest].flatten.join &#39; &#39;}&quot;</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">verbose</span>
  <span class="ruby-keyword">return</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">noop</span>
  <span class="ruby-identifier">fu_each_src_dest</span>(<span class="ruby-identifier">src</span>, <span class="ruby-identifier">dest</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">s</span>, <span class="ruby-identifier">d</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">link_entry</span> <span class="ruby-identifier">s</span>, <span class="ruby-identifier">d</span>, <span class="ruby-identifier">dereference_root</span>, <span class="ruby-identifier">remove_destination</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-cp_r" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">cp_r</span><span
                                class="method-args">(src, dest, preserve: nil, noop: nil, verbose: nil, dereference_root: true, remove_destination: nil)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Recursively copies files.</p>

<p>Arguments <code>src</code> (a single path or an array of paths) and <code>dest</code> (a single path) should be <a href="FileUtils.html#module-FileUtils-label-Path+Arguments">interpretable as paths</a>.</p>

<p>The mode, owner, and group are retained in the copy; to change those, use <a href="FileUtils.html#method-c-install"><code>FileUtils.install</code></a> instead.</p>

<p>If <code>src</code> is the path to a file and <code>dest</code> is not the path to a directory, copies <code>src</code> to <code>dest</code>:</p>

<pre class="ruby"><span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">touch</span>(<span class="ruby-string">&#39;src0.txt&#39;</span>)
<span class="ruby-constant">File</span>.<span class="ruby-identifier">exist?</span>(<span class="ruby-string">&#39;dest0.txt&#39;</span>) <span class="ruby-comment"># =&gt; false</span>
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">cp_r</span>(<span class="ruby-string">&#39;src0.txt&#39;</span>, <span class="ruby-string">&#39;dest0.txt&#39;</span>)
<span class="ruby-constant">File</span>.<span class="ruby-identifier">file?</span>(<span class="ruby-string">&#39;dest0.txt&#39;</span>)  <span class="ruby-comment"># =&gt; true</span>
</pre>

<p>If <code>src</code> is the path to a file and <code>dest</code> is the path to a directory, copies <code>src</code> to <code>dest/src</code>:</p>

<pre class="ruby"><span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">touch</span>(<span class="ruby-string">&#39;src1.txt&#39;</span>)
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">mkdir</span>(<span class="ruby-string">&#39;dest1&#39;</span>)
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">cp_r</span>(<span class="ruby-string">&#39;src1.txt&#39;</span>, <span class="ruby-string">&#39;dest1&#39;</span>)
<span class="ruby-constant">File</span>.<span class="ruby-identifier">file?</span>(<span class="ruby-string">&#39;dest1/src1.txt&#39;</span>) <span class="ruby-comment"># =&gt; true</span>
</pre>

<p>If <code>src</code> is the path to a directory and <code>dest</code> does not exist, recursively copies <code>src</code> to <code>dest</code>:</p>

<pre class="ruby"><span class="ruby-identifier">tree</span>(<span class="ruby-string">&#39;src2&#39;</span>)
<span class="ruby-comment"># =&gt; src2</span>
<span class="ruby-comment">#    |-- dir0</span>
<span class="ruby-comment">#    |   |-- src0.txt</span>
<span class="ruby-comment">#    |   `-- src1.txt</span>
<span class="ruby-comment">#    `-- dir1</span>
<span class="ruby-comment">#    |-- src2.txt</span>
<span class="ruby-comment">#    `-- src3.txt</span>
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">exist?</span>(<span class="ruby-string">&#39;dest2&#39;</span>) <span class="ruby-comment"># =&gt; false</span>
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">cp_r</span>(<span class="ruby-string">&#39;src2&#39;</span>, <span class="ruby-string">&#39;dest2&#39;</span>)
<span class="ruby-identifier">tree</span>(<span class="ruby-string">&#39;dest2&#39;</span>)
<span class="ruby-comment"># =&gt; dest2</span>
<span class="ruby-comment">#    |-- dir0</span>
<span class="ruby-comment">#    |   |-- src0.txt</span>
<span class="ruby-comment">#    |   `-- src1.txt</span>
<span class="ruby-comment">#    `-- dir1</span>
<span class="ruby-comment">#    |-- src2.txt</span>
<span class="ruby-comment">#    `-- src3.txt</span>
</pre>

<p>If <code>src</code> and <code>dest</code> are paths to directories, recursively copies <code>src</code> to <code>dest/src</code>:</p>

<pre class="ruby"><span class="ruby-identifier">tree</span>(<span class="ruby-string">&#39;src3&#39;</span>)
<span class="ruby-comment"># =&gt; src3</span>
<span class="ruby-comment">#    |-- dir0</span>
<span class="ruby-comment">#    |   |-- src0.txt</span>
<span class="ruby-comment">#    |   `-- src1.txt</span>
<span class="ruby-comment">#    `-- dir1</span>
<span class="ruby-comment">#    |-- src2.txt</span>
<span class="ruby-comment">#    `-- src3.txt</span>
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">mkdir</span>(<span class="ruby-string">&#39;dest3&#39;</span>)
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">cp_r</span>(<span class="ruby-string">&#39;src3&#39;</span>, <span class="ruby-string">&#39;dest3&#39;</span>)
<span class="ruby-identifier">tree</span>(<span class="ruby-string">&#39;dest3&#39;</span>)
<span class="ruby-comment"># =&gt; dest3</span>
<span class="ruby-comment">#    `-- src3</span>
<span class="ruby-comment">#      |-- dir0</span>
<span class="ruby-comment">#      |   |-- src0.txt</span>
<span class="ruby-comment">#      |   `-- src1.txt</span>
<span class="ruby-comment">#      `-- dir1</span>
<span class="ruby-comment">#          |-- src2.txt</span>
<span class="ruby-comment">#          `-- src3.txt</span>
</pre>

<p>If <code>src</code> is an array of paths and <code>dest</code> is a directory, recursively copies from each path in <code>src</code> to <code>dest</code>; the paths in <code>src</code> may point to files and/or directories.</p>

<p>Keyword arguments:</p>
<ul><li>
<p><code>dereference_root: false</code> - if <code>src</code> is a symbolic link, does not dereference it.</p>
</li><li>
<p><code>noop: true</code> - does not copy files.</p>
</li><li>
<p><code>preserve: true</code> - preserves file times.</p>
</li><li>
<p><code>remove_destination: true</code> - removes <code>dest</code> before copying files.</p>
</li><li>
<p><code>verbose: true</code> - prints an equivalent command:</p>

<pre class="ruby"><span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">cp_r</span>(<span class="ruby-string">&#39;src0.txt&#39;</span>, <span class="ruby-string">&#39;dest0.txt&#39;</span>, <span class="ruby-value">noop:</span> <span class="ruby-keyword">true</span>, <span class="ruby-value">verbose:</span> <span class="ruby-keyword">true</span>)
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">cp_r</span>(<span class="ruby-string">&#39;src1.txt&#39;</span>, <span class="ruby-string">&#39;dest1&#39;</span>, <span class="ruby-value">noop:</span> <span class="ruby-keyword">true</span>, <span class="ruby-value">verbose:</span> <span class="ruby-keyword">true</span>)
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">cp_r</span>(<span class="ruby-string">&#39;src2&#39;</span>, <span class="ruby-string">&#39;dest2&#39;</span>, <span class="ruby-value">noop:</span> <span class="ruby-keyword">true</span>, <span class="ruby-value">verbose:</span> <span class="ruby-keyword">true</span>)
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">cp_r</span>(<span class="ruby-string">&#39;src3&#39;</span>, <span class="ruby-string">&#39;dest3&#39;</span>, <span class="ruby-value">noop:</span> <span class="ruby-keyword">true</span>, <span class="ruby-value">verbose:</span> <span class="ruby-keyword">true</span>)
</pre>

<p>Output:</p>

<pre>cp -r src0.txt dest0.txt
cp -r src1.txt dest1
cp -r src2 dest2
cp -r src3 dest3</pre>
</li></ul>

<p>Raises an exception of <code>src</code> is the path to a directory and <code>dest</code> is the path to a file.</p>

<p>Related: <a href="FileUtils.html#module-FileUtils-label-Copying">methods for copying</a>.</p>

                              <div class="method-source-code" id="cp_r-source">
            <pre><span class="ruby-comment"># File fileutils.rb, line 985</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">cp_r</span>(<span class="ruby-identifier">src</span>, <span class="ruby-identifier">dest</span>, <span class="ruby-value">preserve:</span> <span class="ruby-keyword">nil</span>, <span class="ruby-value">noop:</span> <span class="ruby-keyword">nil</span>, <span class="ruby-value">verbose:</span> <span class="ruby-keyword">nil</span>,
         <span class="ruby-value">dereference_root:</span> <span class="ruby-keyword">true</span>, <span class="ruby-value">remove_destination:</span> <span class="ruby-keyword">nil</span>)
  <span class="ruby-identifier">fu_output_message</span> <span class="ruby-node">&quot;cp -r#{preserve ? &#39;p&#39; : &#39;&#39;}#{remove_destination ? &#39; --remove-destination&#39; : &#39;&#39;} #{[src,dest].flatten.join &#39; &#39;}&quot;</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">verbose</span>
  <span class="ruby-keyword">return</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">noop</span>
  <span class="ruby-identifier">fu_each_src_dest</span>(<span class="ruby-identifier">src</span>, <span class="ruby-identifier">dest</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">s</span>, <span class="ruby-identifier">d</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">copy_entry</span> <span class="ruby-identifier">s</span>, <span class="ruby-identifier">d</span>, <span class="ruby-identifier">preserve</span>, <span class="ruby-identifier">dereference_root</span>, <span class="ruby-identifier">remove_destination</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-getwd" class="method-detail method-alias">
                            <div class="method-heading">
                              <span class="method-name">getwd</span><span
                                class="method-args">()</span>
                            </div>

                            <div class="method-description">
                              

                            </div>


                            <div class="aliases">
                              Alias for: <a href="FileUtils.html#method-i-pwd">pwd</a>
                            </div>
                          </div>

                  <div id="method-c-have_option-3F" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">have_option?</span><span
                                class="method-args">(mid, opt)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns <code>true</code> if method <code>mid</code> accepts the given option <code>opt</code>, <code>false</code> otherwise; the arguments may be strings or symbols:</p>

<pre class="ruby"><span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">have_option?</span>(<span class="ruby-value">:chmod</span>, <span class="ruby-value">:noop</span>) <span class="ruby-comment"># =&gt; true</span>
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">have_option?</span>(<span class="ruby-string">&#39;chmod&#39;</span>, <span class="ruby-string">&#39;secure&#39;</span>) <span class="ruby-comment"># =&gt; false</span>
</pre>

                              <div class="method-source-code" id="have_option-3F-source">
            <pre><span class="ruby-comment"># File fileutils.rb, line 2588</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">have_option?</span>(<span class="ruby-identifier">mid</span>, <span class="ruby-identifier">opt</span>)
  <span class="ruby-identifier">li</span> = <span class="ruby-constant">OPT_TABLE</span>[<span class="ruby-identifier">mid</span>.<span class="ruby-identifier">to_s</span>] <span class="ruby-keyword">or</span> <span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-node">&quot;no such method: #{mid}&quot;</span>
  <span class="ruby-identifier">li</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">opt</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-identical-3F" class="method-detail method-alias">
                            <div class="method-heading">
                              <span class="method-name">identical?</span><span
                                class="method-args">(a, b)</span>
                            </div>

                            <div class="method-description">
                              

                            </div>


                            <div class="aliases">
                              Alias for: <a href="FileUtils.html#method-i-compare_file">compare_file</a>
                            </div>
                          </div>

                  <div id="method-c-install" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">install</span><span
                                class="method-args">(src, dest, mode: nil, owner: nil, group: nil, preserve: nil, noop: nil, verbose: nil)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Copies a file entry. See <a href="https://man7.org/linux/man-pages/man1/install.1.html">install(1)</a>.</p>

<p>Arguments <code>src</code> (a single path or an array of paths) and <code>dest</code> (a single path) should be <a href="FileUtils.html#module-FileUtils-label-Path+Arguments">interpretable as paths</a>;</p>

<p>If the entry at <code>dest</code> does not exist, copies from <code>src</code> to <code>dest</code>:</p>

<pre class="ruby"><span class="ruby-constant">File</span>.<span class="ruby-identifier">read</span>(<span class="ruby-string">&#39;src0.txt&#39;</span>)    <span class="ruby-comment"># =&gt; &quot;aaa\n&quot;</span>
<span class="ruby-constant">File</span>.<span class="ruby-identifier">exist?</span>(<span class="ruby-string">&#39;dest0.txt&#39;</span>) <span class="ruby-comment"># =&gt; false</span>
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">install</span>(<span class="ruby-string">&#39;src0.txt&#39;</span>, <span class="ruby-string">&#39;dest0.txt&#39;</span>)
<span class="ruby-constant">File</span>.<span class="ruby-identifier">read</span>(<span class="ruby-string">&#39;dest0.txt&#39;</span>)   <span class="ruby-comment"># =&gt; &quot;aaa\n&quot;</span>
</pre>

<p>If <code>dest</code> is a file entry, copies from <code>src</code> to <code>dest</code>, overwriting:</p>

<pre class="ruby"><span class="ruby-constant">File</span>.<span class="ruby-identifier">read</span>(<span class="ruby-string">&#39;src1.txt&#39;</span>)  <span class="ruby-comment"># =&gt; &quot;aaa\n&quot;</span>
<span class="ruby-constant">File</span>.<span class="ruby-identifier">read</span>(<span class="ruby-string">&#39;dest1.txt&#39;</span>) <span class="ruby-comment"># =&gt; &quot;bbb\n&quot;</span>
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">install</span>(<span class="ruby-string">&#39;src1.txt&#39;</span>, <span class="ruby-string">&#39;dest1.txt&#39;</span>)
<span class="ruby-constant">File</span>.<span class="ruby-identifier">read</span>(<span class="ruby-string">&#39;dest1.txt&#39;</span>) <span class="ruby-comment"># =&gt; &quot;aaa\n&quot;</span>
</pre>

<p>If <code>dest</code> is a directory entry, copies from <code>src</code> to <code>dest/src</code>, overwriting if necessary:</p>

<pre class="ruby"><span class="ruby-constant">File</span>.<span class="ruby-identifier">read</span>(<span class="ruby-string">&#39;src2.txt&#39;</span>)       <span class="ruby-comment"># =&gt; &quot;aaa\n&quot;</span>
<span class="ruby-constant">File</span>.<span class="ruby-identifier">read</span>(<span class="ruby-string">&#39;dest2/src2.txt&#39;</span>) <span class="ruby-comment"># =&gt; &quot;bbb\n&quot;</span>
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">install</span>(<span class="ruby-string">&#39;src2.txt&#39;</span>, <span class="ruby-string">&#39;dest2&#39;</span>)
<span class="ruby-constant">File</span>.<span class="ruby-identifier">read</span>(<span class="ruby-string">&#39;dest2/src2.txt&#39;</span>) <span class="ruby-comment"># =&gt; &quot;aaa\n&quot;</span>
</pre>

<p>If <code>src</code> is an array of paths and <code>dest</code> points to a directory, copies each path <code>path</code> in <code>src</code> to <code>dest/path</code>:</p>

<pre class="ruby"><span class="ruby-constant">File</span>.<span class="ruby-identifier">file?</span>(<span class="ruby-string">&#39;src3.txt&#39;</span>) <span class="ruby-comment"># =&gt; true</span>
<span class="ruby-constant">File</span>.<span class="ruby-identifier">file?</span>(<span class="ruby-string">&#39;src3.dat&#39;</span>) <span class="ruby-comment"># =&gt; true</span>
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">mkdir</span>(<span class="ruby-string">&#39;dest3&#39;</span>)
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">install</span>([<span class="ruby-string">&#39;src3.txt&#39;</span>, <span class="ruby-string">&#39;src3.dat&#39;</span>], <span class="ruby-string">&#39;dest3&#39;</span>)
<span class="ruby-constant">File</span>.<span class="ruby-identifier">file?</span>(<span class="ruby-string">&#39;dest3/src3.txt&#39;</span>) <span class="ruby-comment"># =&gt; true</span>
<span class="ruby-constant">File</span>.<span class="ruby-identifier">file?</span>(<span class="ruby-string">&#39;dest3/src3.dat&#39;</span>) <span class="ruby-comment"># =&gt; true</span>
</pre>

<p>Keyword arguments:</p>
<ul><li>
<p><code>group: <em>group</em></code> - changes the group if not <code>nil</code>, using File.chown.</p>
</li><li>
<p><code>mode: <em>permissions</em></code> - changes the permissions. using File.chmod.</p>
</li><li>
<p><code>noop: true</code> - does not copy entries; returns <code>nil</code>.</p>
</li><li>
<p><code>owner: <em>owner</em></code> - changes the owner if not <code>nil</code>, using File.chown.</p>
</li><li>
<p><code>preserve: true</code> - preserve timestamps using File.utime.</p>
</li><li>
<p><code>verbose: true</code> - prints an equivalent command:</p>

<pre class="ruby"><span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">install</span>(<span class="ruby-string">&#39;src0.txt&#39;</span>, <span class="ruby-string">&#39;dest0.txt&#39;</span>, <span class="ruby-value">noop:</span> <span class="ruby-keyword">true</span>, <span class="ruby-value">verbose:</span> <span class="ruby-keyword">true</span>)
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">install</span>(<span class="ruby-string">&#39;src1.txt&#39;</span>, <span class="ruby-string">&#39;dest1.txt&#39;</span>, <span class="ruby-value">noop:</span> <span class="ruby-keyword">true</span>, <span class="ruby-value">verbose:</span> <span class="ruby-keyword">true</span>)
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">install</span>(<span class="ruby-string">&#39;src2.txt&#39;</span>, <span class="ruby-string">&#39;dest2&#39;</span>, <span class="ruby-value">noop:</span> <span class="ruby-keyword">true</span>, <span class="ruby-value">verbose:</span> <span class="ruby-keyword">true</span>)
</pre>

<p>Output:</p>

<pre>install -c src0.txt dest0.txt
install -c src1.txt dest1.txt
install -c src2.txt dest2</pre>
</li></ul>

<p>Related: <a href="FileUtils.html#module-FileUtils-label-Copying">methods for copying</a>.</p>

                              <div class="method-source-code" id="install-source">
            <pre><span class="ruby-comment"># File fileutils.rb, line 1609</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">install</span>(<span class="ruby-identifier">src</span>, <span class="ruby-identifier">dest</span>, <span class="ruby-value">mode:</span> <span class="ruby-keyword">nil</span>, <span class="ruby-value">owner:</span> <span class="ruby-keyword">nil</span>, <span class="ruby-value">group:</span> <span class="ruby-keyword">nil</span>, <span class="ruby-value">preserve:</span> <span class="ruby-keyword">nil</span>,
            <span class="ruby-value">noop:</span> <span class="ruby-keyword">nil</span>, <span class="ruby-value">verbose:</span> <span class="ruby-keyword">nil</span>)
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">verbose</span>
    <span class="ruby-identifier">msg</span> = <span class="ruby-string">+&quot;install -c&quot;</span>
    <span class="ruby-identifier">msg</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-string">&#39; -p&#39;</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">preserve</span>
    <span class="ruby-identifier">msg</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-string">&#39; -m &#39;</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">mode_to_s</span>(<span class="ruby-identifier">mode</span>) <span class="ruby-keyword">if</span> <span class="ruby-identifier">mode</span>
    <span class="ruby-identifier">msg</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-node">&quot; -o #{owner}&quot;</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">owner</span>
    <span class="ruby-identifier">msg</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-node">&quot; -g #{group}&quot;</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">group</span>
    <span class="ruby-identifier">msg</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-string">&#39; &#39;</span> <span class="ruby-operator">&lt;&lt;</span> [<span class="ruby-identifier">src</span>,<span class="ruby-identifier">dest</span>].<span class="ruby-identifier">flatten</span>.<span class="ruby-identifier">join</span>(<span class="ruby-string">&#39; &#39;</span>)
    <span class="ruby-identifier">fu_output_message</span> <span class="ruby-identifier">msg</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">return</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">noop</span>
  <span class="ruby-identifier">uid</span> = <span class="ruby-identifier">fu_get_uid</span>(<span class="ruby-identifier">owner</span>)
  <span class="ruby-identifier">gid</span> = <span class="ruby-identifier">fu_get_gid</span>(<span class="ruby-identifier">group</span>)
  <span class="ruby-identifier">fu_each_src_dest</span>(<span class="ruby-identifier">src</span>, <span class="ruby-identifier">dest</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">s</span>, <span class="ruby-identifier">d</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">st</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">stat</span>(<span class="ruby-identifier">s</span>)
    <span class="ruby-keyword">unless</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">exist?</span>(<span class="ruby-identifier">d</span>) <span class="ruby-keyword">and</span> <span class="ruby-identifier">compare_file</span>(<span class="ruby-identifier">s</span>, <span class="ruby-identifier">d</span>)
      <span class="ruby-identifier">remove_file</span> <span class="ruby-identifier">d</span>, <span class="ruby-keyword">true</span>
      <span class="ruby-keyword">if</span> <span class="ruby-identifier">d</span>.<span class="ruby-identifier">end_with?</span>(<span class="ruby-string">&#39;/&#39;</span>)
        <span class="ruby-identifier">mkdir_p</span> <span class="ruby-identifier">d</span>
        <span class="ruby-identifier">copy_file</span> <span class="ruby-identifier">s</span>, <span class="ruby-identifier">d</span> <span class="ruby-operator">+</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">basename</span>(<span class="ruby-identifier">s</span>)
      <span class="ruby-keyword">else</span>
        <span class="ruby-identifier">mkdir_p</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">expand_path</span>(<span class="ruby-string">&#39;..&#39;</span>, <span class="ruby-identifier">d</span>)
        <span class="ruby-identifier">copy_file</span> <span class="ruby-identifier">s</span>, <span class="ruby-identifier">d</span>
      <span class="ruby-keyword">end</span>
      <span class="ruby-constant">File</span>.<span class="ruby-identifier">utime</span> <span class="ruby-identifier">st</span>.<span class="ruby-identifier">atime</span>, <span class="ruby-identifier">st</span>.<span class="ruby-identifier">mtime</span>, <span class="ruby-identifier">d</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">preserve</span>
      <span class="ruby-constant">File</span>.<span class="ruby-identifier">chmod</span> <span class="ruby-identifier">fu_mode</span>(<span class="ruby-identifier">mode</span>, <span class="ruby-identifier">st</span>), <span class="ruby-identifier">d</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">mode</span>
      <span class="ruby-constant">File</span>.<span class="ruby-identifier">chown</span> <span class="ruby-identifier">uid</span>, <span class="ruby-identifier">gid</span>, <span class="ruby-identifier">d</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">uid</span> <span class="ruby-keyword">or</span> <span class="ruby-identifier">gid</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-link" class="method-detail method-alias">
                            <div class="method-heading">
                              <span class="method-name">link</span><span
                                class="method-args">(src, dest, force: nil, noop: nil, verbose: nil)</span>
                            </div>

                            <div class="method-description">
                              

                            </div>


                            <div class="aliases">
                              Alias for: <a href="FileUtils.html#method-i-ln">ln</a>
                            </div>
                          </div>

                  <div id="method-c-link_entry" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">link_entry</span><span
                                class="method-args">(src, dest, dereference_root = false, remove_destination = false)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Creates <a href="https://en.wikipedia.org/wiki/Hard_link">hard links</a>; returns <code>nil</code>.</p>

<p>Arguments <code>src</code> and <code>dest</code> should be <a href="FileUtils.html#module-FileUtils-label-Path+Arguments">interpretable as paths</a>.</p>

<p>If <code>src</code> is the path to a file and <code>dest</code> does not exist, creates a hard link at <code>dest</code> pointing to <code>src</code>:</p>

<pre class="ruby"><span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">touch</span>(<span class="ruby-string">&#39;src0.txt&#39;</span>)
<span class="ruby-constant">File</span>.<span class="ruby-identifier">exist?</span>(<span class="ruby-string">&#39;dest0.txt&#39;</span>) <span class="ruby-comment"># =&gt; false</span>
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">link_entry</span>(<span class="ruby-string">&#39;src0.txt&#39;</span>, <span class="ruby-string">&#39;dest0.txt&#39;</span>)
<span class="ruby-constant">File</span>.<span class="ruby-identifier">file?</span>(<span class="ruby-string">&#39;dest0.txt&#39;</span>)  <span class="ruby-comment"># =&gt; true</span>
</pre>

<p>If <code>src</code> is the path to a directory and <code>dest</code> does not exist, recursively creates hard links at <code>dest</code> pointing to paths in <code>src</code>:</p>

<pre class="ruby"><span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">mkdir_p</span>([<span class="ruby-string">&#39;src1/dir0&#39;</span>, <span class="ruby-string">&#39;src1/dir1&#39;</span>])
<span class="ruby-identifier">src_file_paths</span> = [
  <span class="ruby-string">&#39;src1/dir0/t0.txt&#39;</span>,
  <span class="ruby-string">&#39;src1/dir0/t1.txt&#39;</span>,
  <span class="ruby-string">&#39;src1/dir1/t2.txt&#39;</span>,
  <span class="ruby-string">&#39;src1/dir1/t3.txt&#39;</span>,
  ]
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">touch</span>(<span class="ruby-identifier">src_file_paths</span>)
<span class="ruby-constant">File</span>.<span class="ruby-identifier">directory?</span>(<span class="ruby-string">&#39;dest1&#39;</span>)        <span class="ruby-comment"># =&gt; true</span>
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">link_entry</span>(<span class="ruby-string">&#39;src1&#39;</span>, <span class="ruby-string">&#39;dest1&#39;</span>)
<span class="ruby-constant">File</span>.<span class="ruby-identifier">file?</span>(<span class="ruby-string">&#39;dest1/dir0/t0.txt&#39;</span>) <span class="ruby-comment"># =&gt; true</span>
<span class="ruby-constant">File</span>.<span class="ruby-identifier">file?</span>(<span class="ruby-string">&#39;dest1/dir0/t1.txt&#39;</span>) <span class="ruby-comment"># =&gt; true</span>
<span class="ruby-constant">File</span>.<span class="ruby-identifier">file?</span>(<span class="ruby-string">&#39;dest1/dir1/t2.txt&#39;</span>) <span class="ruby-comment"># =&gt; true</span>
<span class="ruby-constant">File</span>.<span class="ruby-identifier">file?</span>(<span class="ruby-string">&#39;dest1/dir1/t3.txt&#39;</span>) <span class="ruby-comment"># =&gt; true</span>
</pre>

<p>Keyword arguments:</p>
<ul><li>
<p><code>dereference_root: true</code> - dereferences <code>src</code> if it is a symbolic link.</p>
</li><li>
<p><code>remove_destination: true</code> - removes <code>dest</code> before creating links.</p>
</li></ul>

<p>Raises an exception if <code>dest</code> is the path to an existing file or directory and keyword argument <code>remove_destination: true</code> is not given.</p>

<p>Related: <a href="FileUtils.html#method-c-ln"><code>FileUtils.ln</code></a> (has different options).</p>

                              <div class="method-source-code" id="link_entry-source">
            <pre><span class="ruby-comment"># File fileutils.rb, line 812</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">link_entry</span>(<span class="ruby-identifier">src</span>, <span class="ruby-identifier">dest</span>, <span class="ruby-identifier">dereference_root</span> = <span class="ruby-keyword">false</span>, <span class="ruby-identifier">remove_destination</span> = <span class="ruby-keyword">false</span>)
  <span class="ruby-constant">Entry_</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">src</span>, <span class="ruby-keyword">nil</span>, <span class="ruby-identifier">dereference_root</span>).<span class="ruby-identifier">traverse</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">ent</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">destent</span> = <span class="ruby-constant">Entry_</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">dest</span>, <span class="ruby-identifier">ent</span>.<span class="ruby-identifier">rel</span>, <span class="ruby-keyword">false</span>)
    <span class="ruby-constant">File</span>.<span class="ruby-identifier">unlink</span> <span class="ruby-identifier">destent</span>.<span class="ruby-identifier">path</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">remove_destination</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">file?</span>(<span class="ruby-identifier">destent</span>.<span class="ruby-identifier">path</span>)
    <span class="ruby-identifier">ent</span>.<span class="ruby-identifier">link</span> <span class="ruby-identifier">destent</span>.<span class="ruby-identifier">path</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-ln" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">ln</span><span
                                class="method-args">(src, dest, force: nil, noop: nil, verbose: nil)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Creates <a href="https://en.wikipedia.org/wiki/Hard_link">hard links</a>.</p>

<p>Arguments <code>src</code> (a single path or an array of paths) and <code>dest</code> (a single path) should be <a href="FileUtils.html#module-FileUtils-label-Path+Arguments">interpretable as paths</a>.</p>

<p>When <code>src</code> is the path to an existing file and <code>dest</code> is the path to a non-existent file, creates a hard link at <code>dest</code> pointing to <code>src</code>; returns zero:</p>

<pre class="ruby"><span class="ruby-constant">Dir</span>.<span class="ruby-identifier">children</span>(<span class="ruby-string">&#39;tmp0/&#39;</span>)                    <span class="ruby-comment"># =&gt; [&quot;t.txt&quot;]</span>
<span class="ruby-constant">Dir</span>.<span class="ruby-identifier">children</span>(<span class="ruby-string">&#39;tmp1/&#39;</span>)                    <span class="ruby-comment"># =&gt; []</span>
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">ln</span>(<span class="ruby-string">&#39;tmp0/t.txt&#39;</span>, <span class="ruby-string">&#39;tmp1/t.lnk&#39;</span>) <span class="ruby-comment"># =&gt; 0</span>
<span class="ruby-constant">Dir</span>.<span class="ruby-identifier">children</span>(<span class="ruby-string">&#39;tmp1/&#39;</span>)                    <span class="ruby-comment"># =&gt; [&quot;t.lnk&quot;]</span>
</pre>

<p>When <code>src</code> is the path to an existing file and <code>dest</code> is the path to an existing directory, creates a hard link at <code>dest/src</code> pointing to <code>src</code>; returns zero:</p>

<pre class="ruby"><span class="ruby-constant">Dir</span>.<span class="ruby-identifier">children</span>(<span class="ruby-string">&#39;tmp2&#39;</span>)               <span class="ruby-comment"># =&gt; [&quot;t.dat&quot;]</span>
<span class="ruby-constant">Dir</span>.<span class="ruby-identifier">children</span>(<span class="ruby-string">&#39;tmp3&#39;</span>)               <span class="ruby-comment"># =&gt; []</span>
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">ln</span>(<span class="ruby-string">&#39;tmp2/t.dat&#39;</span>, <span class="ruby-string">&#39;tmp3&#39;</span>) <span class="ruby-comment"># =&gt; 0</span>
<span class="ruby-constant">Dir</span>.<span class="ruby-identifier">children</span>(<span class="ruby-string">&#39;tmp3&#39;</span>)               <span class="ruby-comment"># =&gt; [&quot;t.dat&quot;]</span>
</pre>

<p>When <code>src</code> is an array of paths to existing files and <code>dest</code> is the path to an existing directory, then for each path <code>target</code> in <code>src</code>, creates a hard link at <code>dest/target</code> pointing to <code>target</code>; returns <code>src</code>:</p>

<pre class="ruby"><span class="ruby-constant">Dir</span>.<span class="ruby-identifier">children</span>(<span class="ruby-string">&#39;tmp4/&#39;</span>)                               <span class="ruby-comment"># =&gt; []</span>
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">ln</span>([<span class="ruby-string">&#39;tmp0/t.txt&#39;</span>, <span class="ruby-string">&#39;tmp2/t.dat&#39;</span>], <span class="ruby-string">&#39;tmp4/&#39;</span>) <span class="ruby-comment"># =&gt; [&quot;tmp0/t.txt&quot;, &quot;tmp2/t.dat&quot;]</span>
<span class="ruby-constant">Dir</span>.<span class="ruby-identifier">children</span>(<span class="ruby-string">&#39;tmp4/&#39;</span>)                               <span class="ruby-comment"># =&gt; [&quot;t.dat&quot;, &quot;t.txt&quot;]</span>
</pre>

<p>Keyword arguments:</p>
<ul><li>
<p><code>force: true</code> - overwrites <code>dest</code> if it exists.</p>
</li><li>
<p><code>noop: true</code> - does not create links.</p>
</li><li>
<p><code>verbose: true</code> - prints an equivalent command:</p>

<pre class="ruby"><span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">ln</span>(<span class="ruby-string">&#39;tmp0/t.txt&#39;</span>, <span class="ruby-string">&#39;tmp1/t.lnk&#39;</span>, <span class="ruby-value">verbose:</span> <span class="ruby-keyword">true</span>)
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">ln</span>(<span class="ruby-string">&#39;tmp2/t.dat&#39;</span>, <span class="ruby-string">&#39;tmp3&#39;</span>, <span class="ruby-value">verbose:</span> <span class="ruby-keyword">true</span>)
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">ln</span>([<span class="ruby-string">&#39;tmp0/t.txt&#39;</span>, <span class="ruby-string">&#39;tmp2/t.dat&#39;</span>], <span class="ruby-string">&#39;tmp4/&#39;</span>, <span class="ruby-value">verbose:</span> <span class="ruby-keyword">true</span>)
</pre>

<p>Output:</p>

<pre>ln tmp0/t.txt tmp1/t.lnk
ln tmp2/t.dat tmp3
ln tmp0/t.txt tmp2/t.dat tmp4/</pre>
</li></ul>

<p>Raises an exception if <code>dest</code> is the path to an existing file and keyword argument <code>force</code> is not <code>true</code>.</p>

<p>Related: <a href="FileUtils.html#method-c-link_entry"><code>FileUtils.link_entry</code></a> (has different options).</p>

                              <div class="method-source-code" id="ln-source">
            <pre><span class="ruby-comment"># File fileutils.rb, line 516</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">ln</span>(<span class="ruby-identifier">src</span>, <span class="ruby-identifier">dest</span>, <span class="ruby-value">force:</span> <span class="ruby-keyword">nil</span>, <span class="ruby-value">noop:</span> <span class="ruby-keyword">nil</span>, <span class="ruby-value">verbose:</span> <span class="ruby-keyword">nil</span>)
  <span class="ruby-identifier">fu_output_message</span> <span class="ruby-node">&quot;ln#{force ? &#39; -f&#39; : &#39;&#39;} #{[src,dest].flatten.join &#39; &#39;}&quot;</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">verbose</span>
  <span class="ruby-keyword">return</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">noop</span>
  <span class="ruby-identifier">fu_each_src_dest0</span>(<span class="ruby-identifier">src</span>, <span class="ruby-identifier">dest</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">s</span>,<span class="ruby-identifier">d</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">remove_file</span> <span class="ruby-identifier">d</span>, <span class="ruby-keyword">true</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">force</span>
    <span class="ruby-constant">File</span>.<span class="ruby-identifier">link</span> <span class="ruby-identifier">s</span>, <span class="ruby-identifier">d</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>

                            <div class="aliases">
                              Also aliased as: <a href="FileUtils.html#method-i-link">link</a>
                            </div>

                          </div>

                  <div id="method-c-ln_s" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">ln_s</span><span
                                class="method-args">(src, dest, force: nil, relative: false, target_directory: true, noop: nil, verbose: nil)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Creates <a href="https://en.wikipedia.org/wiki/Symbolic_link">symbolic links</a>.</p>

<p>Arguments <code>src</code> (a single path or an array of paths) and <code>dest</code> (a single path) should be <a href="FileUtils.html#module-FileUtils-label-Path+Arguments">interpretable as paths</a>.</p>

<p>If <code>src</code> is the path to an existing file:</p>
<ul><li>
<p>When <code>dest</code> is the path to a non-existent file, creates a symbolic link at <code>dest</code> pointing to <code>src</code>:</p>

<pre class="ruby"><span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">touch</span>(<span class="ruby-string">&#39;src0.txt&#39;</span>)
<span class="ruby-constant">File</span>.<span class="ruby-identifier">exist?</span>(<span class="ruby-string">&#39;dest0.txt&#39;</span>)   <span class="ruby-comment"># =&gt; false</span>
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">ln_s</span>(<span class="ruby-string">&#39;src0.txt&#39;</span>, <span class="ruby-string">&#39;dest0.txt&#39;</span>)
<span class="ruby-constant">File</span>.<span class="ruby-identifier">symlink?</span>(<span class="ruby-string">&#39;dest0.txt&#39;</span>) <span class="ruby-comment"># =&gt; true</span>
</pre>
</li><li>
<p>When <code>dest</code> is the path to an existing file, creates a symbolic link at <code>dest</code> pointing to <code>src</code> if and only if keyword argument <code>force: true</code> is given (raises an exception otherwise):</p>

<pre class="ruby"><span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">touch</span>(<span class="ruby-string">&#39;src1.txt&#39;</span>)
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">touch</span>(<span class="ruby-string">&#39;dest1.txt&#39;</span>)
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">ln_s</span>(<span class="ruby-string">&#39;src1.txt&#39;</span>, <span class="ruby-string">&#39;dest1.txt&#39;</span>, <span class="ruby-value">force:</span> <span class="ruby-keyword">true</span>)
<span class="ruby-constant">FileTest</span>.<span class="ruby-identifier">symlink?</span>(<span class="ruby-string">&#39;dest1.txt&#39;</span>) <span class="ruby-comment"># =&gt; true</span>

<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">ln_s</span>(<span class="ruby-string">&#39;src1.txt&#39;</span>, <span class="ruby-string">&#39;dest1.txt&#39;</span>) <span class="ruby-comment"># Raises Errno::EEXIST.</span>
</pre>
</li></ul>

<p>If <code>dest</code> is the path to a directory, creates a symbolic link at <code>dest/src</code> pointing to <code>src</code>:</p>

<pre class="ruby"><span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">touch</span>(<span class="ruby-string">&#39;src2.txt&#39;</span>)
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">mkdir</span>(<span class="ruby-string">&#39;destdir2&#39;</span>)
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">ln_s</span>(<span class="ruby-string">&#39;src2.txt&#39;</span>, <span class="ruby-string">&#39;destdir2&#39;</span>)
<span class="ruby-constant">File</span>.<span class="ruby-identifier">symlink?</span>(<span class="ruby-string">&#39;destdir2/src2.txt&#39;</span>) <span class="ruby-comment"># =&gt; true</span>
</pre>

<p>If <code>src</code> is an array of paths to existing files and <code>dest</code> is a directory, for each child <code>child</code> in <code>src</code> creates a symbolic link <code>dest/child</code> pointing to <code>child</code>:</p>

<pre class="ruby"><span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">mkdir</span>(<span class="ruby-string">&#39;srcdir3&#39;</span>)
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">touch</span>(<span class="ruby-string">&#39;srcdir3/src0.txt&#39;</span>)
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">touch</span>(<span class="ruby-string">&#39;srcdir3/src1.txt&#39;</span>)
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">mkdir</span>(<span class="ruby-string">&#39;destdir3&#39;</span>)
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">ln_s</span>([<span class="ruby-string">&#39;srcdir3/src0.txt&#39;</span>, <span class="ruby-string">&#39;srcdir3/src1.txt&#39;</span>], <span class="ruby-string">&#39;destdir3&#39;</span>)
<span class="ruby-constant">File</span>.<span class="ruby-identifier">symlink?</span>(<span class="ruby-string">&#39;destdir3/src0.txt&#39;</span>) <span class="ruby-comment"># =&gt; true</span>
<span class="ruby-constant">File</span>.<span class="ruby-identifier">symlink?</span>(<span class="ruby-string">&#39;destdir3/src1.txt&#39;</span>) <span class="ruby-comment"># =&gt; true</span>
</pre>

<p>Keyword arguments:</p>
<ul><li>
<p><code>force: true</code> - overwrites <code>dest</code> if it exists.</p>
</li><li>
<p><code>relative: false</code> - create links relative to <code>dest</code>.</p>
</li><li>
<p><code>noop: true</code> - does not create links.</p>
</li><li>
<p><code>verbose: true</code> - prints an equivalent command:</p>

<pre class="ruby"><span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">ln_s</span>(<span class="ruby-string">&#39;src0.txt&#39;</span>, <span class="ruby-string">&#39;dest0.txt&#39;</span>, <span class="ruby-value">noop:</span> <span class="ruby-keyword">true</span>, <span class="ruby-value">verbose:</span> <span class="ruby-keyword">true</span>)
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">ln_s</span>(<span class="ruby-string">&#39;src1.txt&#39;</span>, <span class="ruby-string">&#39;destdir1&#39;</span>, <span class="ruby-value">noop:</span> <span class="ruby-keyword">true</span>, <span class="ruby-value">verbose:</span> <span class="ruby-keyword">true</span>)
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">ln_s</span>(<span class="ruby-string">&#39;src2.txt&#39;</span>, <span class="ruby-string">&#39;dest2.txt&#39;</span>, <span class="ruby-value">force:</span> <span class="ruby-keyword">true</span>, <span class="ruby-value">noop:</span> <span class="ruby-keyword">true</span>, <span class="ruby-value">verbose:</span> <span class="ruby-keyword">true</span>)
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">ln_s</span>([<span class="ruby-string">&#39;srcdir3/src0.txt&#39;</span>, <span class="ruby-string">&#39;srcdir3/src1.txt&#39;</span>], <span class="ruby-string">&#39;destdir3&#39;</span>, <span class="ruby-value">noop:</span> <span class="ruby-keyword">true</span>, <span class="ruby-value">verbose:</span> <span class="ruby-keyword">true</span>)
</pre>

<p>Output:</p>

<pre>ln -s src0.txt dest0.txt
ln -s src1.txt destdir1
ln -sf src2.txt dest2.txt
ln -s srcdir3/src0.txt srcdir3/src1.txt destdir3</pre>
</li></ul>

<p>Related: <a href="FileUtils.html#method-c-ln_sf"><code>FileUtils.ln_sf</code></a>.</p>

                              <div class="method-source-code" id="ln_s-source">
            <pre><span class="ruby-comment"># File fileutils.rb, line 706</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">ln_s</span>(<span class="ruby-identifier">src</span>, <span class="ruby-identifier">dest</span>, <span class="ruby-value">force:</span> <span class="ruby-keyword">nil</span>, <span class="ruby-value">relative:</span> <span class="ruby-keyword">false</span>, <span class="ruby-value">target_directory:</span> <span class="ruby-keyword">true</span>, <span class="ruby-value">noop:</span> <span class="ruby-keyword">nil</span>, <span class="ruby-value">verbose:</span> <span class="ruby-keyword">nil</span>)
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">relative</span>
    <span class="ruby-keyword">return</span> <span class="ruby-identifier">ln_sr</span>(<span class="ruby-identifier">src</span>, <span class="ruby-identifier">dest</span>, <span class="ruby-value">force:</span> <span class="ruby-identifier">force</span>, <span class="ruby-value">noop:</span> <span class="ruby-identifier">noop</span>, <span class="ruby-value">verbose:</span> <span class="ruby-identifier">verbose</span>)
  <span class="ruby-keyword">end</span>
  <span class="ruby-identifier">fu_output_message</span> <span class="ruby-node">&quot;ln -s#{force ? &#39;f&#39; : &#39;&#39;} #{[src,dest].flatten.join &#39; &#39;}&quot;</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">verbose</span>
  <span class="ruby-keyword">return</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">noop</span>
  <span class="ruby-identifier">fu_each_src_dest0</span>(<span class="ruby-identifier">src</span>, <span class="ruby-identifier">dest</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">s</span>,<span class="ruby-identifier">d</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">remove_file</span> <span class="ruby-identifier">d</span>, <span class="ruby-keyword">true</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">force</span>
    <span class="ruby-constant">File</span>.<span class="ruby-identifier">symlink</span> <span class="ruby-identifier">s</span>, <span class="ruby-identifier">d</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>

                            <div class="aliases">
                              Also aliased as: <a href="FileUtils.html#method-i-symlink">symlink</a>
                            </div>

                          </div>

                  <div id="method-c-ln_sf" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">ln_sf</span><span
                                class="method-args">(src, dest, noop: nil, verbose: nil)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Like <a href="FileUtils.html#method-c-ln_s"><code>FileUtils.ln_s</code></a>, but always with keyword argument <code>force: true</code> given.</p>

                              <div class="method-source-code" id="ln_sf-source">
            <pre><span class="ruby-comment"># File fileutils.rb, line 724</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">ln_sf</span>(<span class="ruby-identifier">src</span>, <span class="ruby-identifier">dest</span>, <span class="ruby-value">noop:</span> <span class="ruby-keyword">nil</span>, <span class="ruby-value">verbose:</span> <span class="ruby-keyword">nil</span>)
  <span class="ruby-identifier">ln_s</span> <span class="ruby-identifier">src</span>, <span class="ruby-identifier">dest</span>, <span class="ruby-value">force:</span> <span class="ruby-keyword">true</span>, <span class="ruby-value">noop:</span> <span class="ruby-identifier">noop</span>, <span class="ruby-value">verbose:</span> <span class="ruby-identifier">verbose</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-ln_sr" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">ln_sr</span><span
                                class="method-args">(src, dest, target_directory: true, force: nil, noop: nil, verbose: nil)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Like <a href="FileUtils.html#method-c-ln_s"><code>FileUtils.ln_s</code></a>, but create links relative to <code>dest</code>.</p>

                              <div class="method-source-code" id="ln_sr-source">
            <pre><span class="ruby-comment"># File fileutils.rb, line 731</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">ln_sr</span>(<span class="ruby-identifier">src</span>, <span class="ruby-identifier">dest</span>, <span class="ruby-value">target_directory:</span> <span class="ruby-keyword">true</span>, <span class="ruby-value">force:</span> <span class="ruby-keyword">nil</span>, <span class="ruby-value">noop:</span> <span class="ruby-keyword">nil</span>, <span class="ruby-value">verbose:</span> <span class="ruby-keyword">nil</span>)
  <span class="ruby-identifier">options</span> = <span class="ruby-node">&quot;#{force ? &#39;f&#39; : &#39;&#39;}#{target_directory ? &#39;&#39; : &#39;T&#39;}&quot;</span>
  <span class="ruby-identifier">dest</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">path</span>(<span class="ruby-identifier">dest</span>)
  <span class="ruby-identifier">srcs</span> = <span class="ruby-constant">Array</span>(<span class="ruby-identifier">src</span>)
  <span class="ruby-identifier">link</span> = <span class="ruby-identifier">proc</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">s</span>, <span class="ruby-identifier">target_dir_p</span> = <span class="ruby-keyword">true</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">s</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">path</span>(<span class="ruby-identifier">s</span>)
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">target_dir_p</span>
      <span class="ruby-identifier">d</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-identifier">destdirs</span> = <span class="ruby-identifier">dest</span>, <span class="ruby-constant">File</span>.<span class="ruby-identifier">basename</span>(<span class="ruby-identifier">s</span>))
    <span class="ruby-keyword">else</span>
      <span class="ruby-identifier">destdirs</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">dirname</span>(<span class="ruby-identifier">d</span> = <span class="ruby-identifier">dest</span>)
    <span class="ruby-keyword">end</span>
    <span class="ruby-identifier">destdirs</span> = <span class="ruby-identifier">fu_split_path</span>(<span class="ruby-constant">File</span>.<span class="ruby-identifier">realpath</span>(<span class="ruby-identifier">destdirs</span>))
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">fu_starting_path?</span>(<span class="ruby-identifier">s</span>)
      <span class="ruby-identifier">srcdirs</span> = <span class="ruby-identifier">fu_split_path</span>((<span class="ruby-constant">File</span>.<span class="ruby-identifier">realdirpath</span>(<span class="ruby-identifier">s</span>) <span class="ruby-keyword">rescue</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">expand_path</span>(<span class="ruby-identifier">s</span>)))
      <span class="ruby-identifier">base</span> = <span class="ruby-identifier">fu_relative_components_from</span>(<span class="ruby-identifier">srcdirs</span>, <span class="ruby-identifier">destdirs</span>)
      <span class="ruby-identifier">s</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">base</span>)
    <span class="ruby-keyword">else</span>
      <span class="ruby-identifier">srcdirs</span> = <span class="ruby-identifier">fu_clean_components</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">fu_split_path</span>(<span class="ruby-identifier">s</span>))
      <span class="ruby-identifier">base</span> = <span class="ruby-identifier">fu_relative_components_from</span>(<span class="ruby-identifier">fu_split_path</span>(<span class="ruby-constant">Dir</span>.<span class="ruby-identifier">pwd</span>), <span class="ruby-identifier">destdirs</span>)
      <span class="ruby-keyword">while</span> <span class="ruby-identifier">srcdirs</span>.<span class="ruby-identifier">first</span>&amp;. <span class="ruby-identifier">==</span> <span class="ruby-string">&quot;..&quot;</span> <span class="ruby-keyword">and</span> <span class="ruby-identifier">base</span>.<span class="ruby-identifier">last</span>&amp;.<span class="ruby-identifier">!=</span>(<span class="ruby-string">&quot;..&quot;</span>) <span class="ruby-keyword">and</span> <span class="ruby-operator">!</span><span class="ruby-identifier">fu_starting_path?</span>(<span class="ruby-identifier">base</span>.<span class="ruby-identifier">last</span>)
        <span class="ruby-identifier">srcdirs</span>.<span class="ruby-identifier">shift</span>
        <span class="ruby-identifier">base</span>.<span class="ruby-identifier">pop</span>
      <span class="ruby-keyword">end</span>
      <span class="ruby-identifier">s</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">base</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">srcdirs</span>)
    <span class="ruby-keyword">end</span>
    <span class="ruby-identifier">fu_output_message</span> <span class="ruby-node">&quot;ln -s#{options} #{s} #{d}&quot;</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">verbose</span>
    <span class="ruby-keyword">next</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">noop</span>
    <span class="ruby-identifier">remove_file</span> <span class="ruby-identifier">d</span>, <span class="ruby-keyword">true</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">force</span>
    <span class="ruby-constant">File</span>.<span class="ruby-identifier">symlink</span> <span class="ruby-identifier">s</span>, <span class="ruby-identifier">d</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">case</span> <span class="ruby-identifier">srcs</span>.<span class="ruby-identifier">size</span>
  <span class="ruby-keyword">when</span> <span class="ruby-value">0</span>
  <span class="ruby-keyword">when</span> <span class="ruby-value">1</span>
    <span class="ruby-identifier">link</span>[<span class="ruby-identifier">srcs</span>[<span class="ruby-value">0</span>], <span class="ruby-identifier">target_directory</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">directory?</span>(<span class="ruby-identifier">dest</span>)]
  <span class="ruby-keyword">else</span>
    <span class="ruby-identifier">srcs</span>.<span class="ruby-identifier">each</span>(<span class="ruby-operator">&amp;</span><span class="ruby-identifier">link</span>)
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-makedirs" class="method-detail method-alias">
                            <div class="method-heading">
                              <span class="method-name">makedirs</span><span
                                class="method-args">(list, mode: nil, noop: nil, verbose: nil)</span>
                            </div>

                            <div class="method-description">
                              

                            </div>


                            <div class="aliases">
                              Alias for: <a href="FileUtils.html#method-i-mkdir_p">mkdir_p</a>
                            </div>
                          </div>

                  <div id="method-c-mkdir" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">mkdir</span><span
                                class="method-args">(list, mode: nil, noop: nil, verbose: nil)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Creates directories at the paths in the given <code>list</code> (a single path or an array of paths); returns <code>list</code> if it is an array, <code>[list]</code> otherwise.</p>

<p>Argument <code>list</code> or its elements should be <a href="FileUtils.html#module-FileUtils-label-Path+Arguments">interpretable as paths</a>.</p>

<p>With no keyword arguments, creates a directory at each <code>path</code> in <code>list</code> by calling: <code>Dir.mkdir(path, mode)</code>; see Dir.mkdir:</p>

<pre class="ruby"><span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">mkdir</span>(<span class="ruby-node">%w[tmp0 tmp1]</span>) <span class="ruby-comment"># =&gt; [&quot;tmp0&quot;, &quot;tmp1&quot;]</span>
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">mkdir</span>(<span class="ruby-string">&#39;tmp4&#39;</span>)        <span class="ruby-comment"># =&gt; [&quot;tmp4&quot;]</span>
</pre>

<p>Keyword arguments:</p>
<ul><li>
<p><code>mode: <em>mode</em></code> - also calls <code>File.chmod(mode, path)</code>; see File.chmod.</p>
</li><li>
<p><code>noop: true</code> - does not create directories.</p>
</li><li>
<p><code>verbose: true</code> - prints an equivalent command:</p>

<pre class="ruby"><span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">mkdir</span>(<span class="ruby-node">%w[tmp0 tmp1]</span>, <span class="ruby-value">verbose:</span> <span class="ruby-keyword">true</span>)
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">mkdir</span>(<span class="ruby-node">%w[tmp2 tmp3]</span>, <span class="ruby-value">mode:</span> <span class="ruby-value">0700</span>, <span class="ruby-value">verbose:</span> <span class="ruby-keyword">true</span>)
</pre>

<p>Output:</p>

<pre>mkdir tmp0 tmp1
mkdir -m 700 tmp2 tmp3</pre>
</li></ul>

<p>Raises an exception if any path points to an existing file or directory, or if for any reason a directory cannot be created.</p>

<p>Related: <a href="FileUtils.html#method-c-mkdir_p"><code>FileUtils.mkdir_p</code></a>.</p>

                              <div class="method-source-code" id="mkdir-source">
            <pre><span class="ruby-comment"># File fileutils.rb, line 316</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">mkdir</span>(<span class="ruby-identifier">list</span>, <span class="ruby-value">mode:</span> <span class="ruby-keyword">nil</span>, <span class="ruby-value">noop:</span> <span class="ruby-keyword">nil</span>, <span class="ruby-value">verbose:</span> <span class="ruby-keyword">nil</span>)
  <span class="ruby-identifier">list</span> = <span class="ruby-identifier">fu_list</span>(<span class="ruby-identifier">list</span>)
  <span class="ruby-identifier">fu_output_message</span> <span class="ruby-node">&quot;mkdir #{mode ? (&#39;-m %03o &#39; % mode) : &#39;&#39;}#{list.join &#39; &#39;}&quot;</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">verbose</span>
  <span class="ruby-keyword">return</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">noop</span>

  <span class="ruby-identifier">list</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">dir</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">fu_mkdir</span> <span class="ruby-identifier">dir</span>, <span class="ruby-identifier">mode</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-mkdir_p" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">mkdir_p</span><span
                                class="method-args">(list, mode: nil, noop: nil, verbose: nil)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Creates directories at the paths in the given <code>list</code> (a single path or an array of paths), also creating ancestor directories as needed; returns <code>list</code> if it is an array, <code>[list]</code> otherwise.</p>

<p>Argument <code>list</code> or its elements should be <a href="FileUtils.html#module-FileUtils-label-Path+Arguments">interpretable as paths</a>.</p>

<p>With no keyword arguments, creates a directory at each <code>path</code> in <code>list</code>, along with any needed ancestor directories, by calling: <code>Dir.mkdir(path, mode)</code>; see Dir.mkdir:</p>

<pre class="ruby"><span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">mkdir_p</span>(<span class="ruby-node">%w[tmp0/tmp1 tmp2/tmp3]</span>) <span class="ruby-comment"># =&gt; [&quot;tmp0/tmp1&quot;, &quot;tmp2/tmp3&quot;]</span>
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">mkdir_p</span>(<span class="ruby-string">&#39;tmp4/tmp5&#39;</span>)             <span class="ruby-comment"># =&gt; [&quot;tmp4/tmp5&quot;]</span>
</pre>

<p>Keyword arguments:</p>
<ul><li>
<p><code>mode: <em>mode</em></code> - also calls <code>File.chmod(mode, path)</code>; see File.chmod.</p>
</li><li>
<p><code>noop: true</code> - does not create directories.</p>
</li><li>
<p><code>verbose: true</code> - prints an equivalent command:</p>

<pre class="ruby"><span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">mkdir_p</span>(<span class="ruby-node">%w[tmp0 tmp1]</span>, <span class="ruby-value">verbose:</span> <span class="ruby-keyword">true</span>)
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">mkdir_p</span>(<span class="ruby-node">%w[tmp2 tmp3]</span>, <span class="ruby-value">mode:</span> <span class="ruby-value">0700</span>, <span class="ruby-value">verbose:</span> <span class="ruby-keyword">true</span>)
</pre>

<p>Output:</p>

<pre>mkdir -p tmp0 tmp1
mkdir -p -m 700 tmp2 tmp3</pre>
</li></ul>

<p>Raises an exception if for any reason a directory cannot be created.</p>

<p><a href="FileUtils.html#method-c-mkpath"><code>FileUtils.mkpath</code></a> and <a href="FileUtils.html#method-c-makedirs"><code>FileUtils.makedirs</code></a> are aliases for <a href="FileUtils.html#method-c-mkdir_p"><code>FileUtils.mkdir_p</code></a>.</p>

<p>Related: <a href="FileUtils.html#method-c-mkdir"><code>FileUtils.mkdir</code></a>.</p>

                              <div class="method-source-code" id="mkdir_p-source">
            <pre><span class="ruby-comment"># File fileutils.rb, line 365</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">mkdir_p</span>(<span class="ruby-identifier">list</span>, <span class="ruby-value">mode:</span> <span class="ruby-keyword">nil</span>, <span class="ruby-value">noop:</span> <span class="ruby-keyword">nil</span>, <span class="ruby-value">verbose:</span> <span class="ruby-keyword">nil</span>)
  <span class="ruby-identifier">list</span> = <span class="ruby-identifier">fu_list</span>(<span class="ruby-identifier">list</span>)
  <span class="ruby-identifier">fu_output_message</span> <span class="ruby-node">&quot;mkdir -p #{mode ? (&#39;-m %03o &#39; % mode) : &#39;&#39;}#{list.join &#39; &#39;}&quot;</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">verbose</span>
  <span class="ruby-keyword">return</span> <span class="ruby-operator">*</span><span class="ruby-identifier">list</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">noop</span>

  <span class="ruby-identifier">list</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">item</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">path</span> = <span class="ruby-identifier">remove_trailing_slash</span>(<span class="ruby-identifier">item</span>)

    <span class="ruby-identifier">stack</span> = []
    <span class="ruby-keyword">until</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">directory?</span>(<span class="ruby-identifier">path</span>) <span class="ruby-operator">||</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">dirname</span>(<span class="ruby-identifier">path</span>) <span class="ruby-operator">==</span> <span class="ruby-identifier">path</span>
      <span class="ruby-identifier">stack</span>.<span class="ruby-identifier">push</span> <span class="ruby-identifier">path</span>
      <span class="ruby-identifier">path</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">dirname</span>(<span class="ruby-identifier">path</span>)
    <span class="ruby-keyword">end</span>
    <span class="ruby-identifier">stack</span>.<span class="ruby-identifier">reverse_each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">dir</span><span class="ruby-operator">|</span>
      <span class="ruby-keyword">begin</span>
        <span class="ruby-identifier">fu_mkdir</span> <span class="ruby-identifier">dir</span>, <span class="ruby-identifier">mode</span>
      <span class="ruby-keyword">rescue</span> <span class="ruby-constant">SystemCallError</span>
        <span class="ruby-identifier">raise</span> <span class="ruby-keyword">unless</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">directory?</span>(<span class="ruby-identifier">dir</span>)
      <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-keyword">return</span> <span class="ruby-operator">*</span><span class="ruby-identifier">list</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>

                            <div class="aliases">
                              Also aliased as: <a href="FileUtils.html#method-i-mkpath">mkpath</a>, <a href="FileUtils.html#method-i-makedirs">makedirs</a>
                            </div>

                          </div>

                  <div id="method-c-mkpath" class="method-detail method-alias">
                            <div class="method-heading">
                              <span class="method-name">mkpath</span><span
                                class="method-args">(list, mode: nil, noop: nil, verbose: nil)</span>
                            </div>

                            <div class="method-description">
                              

                            </div>


                            <div class="aliases">
                              Alias for: <a href="FileUtils.html#method-i-mkdir_p">mkdir_p</a>
                            </div>
                          </div>

                  <div id="method-c-move" class="method-detail method-alias">
                            <div class="method-heading">
                              <span class="method-name">move</span><span
                                class="method-args">(src, dest, force: nil, noop: nil, verbose: nil, secure: nil)</span>
                            </div>

                            <div class="method-description">
                              

                            </div>


                            <div class="aliases">
                              Alias for: <a href="FileUtils.html#method-i-mv">mv</a>
                            </div>
                          </div>

                  <div id="method-c-mv" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">mv</span><span
                                class="method-args">(src, dest, force: nil, noop: nil, verbose: nil, secure: nil)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Moves entries.</p>

<p>Arguments <code>src</code> (a single path or an array of paths) and <code>dest</code> (a single path) should be <a href="FileUtils.html#module-FileUtils-label-Path+Arguments">interpretable as paths</a>.</p>

<p>If <code>src</code> and <code>dest</code> are on different file systems, first copies, then removes <code>src</code>.</p>

<p>May cause a local vulnerability if not called with keyword argument <code>secure: true</code>; see <a href="FileUtils.html#module-FileUtils-label-Avoiding+the+TOCTTOU+Vulnerability">Avoiding the TOCTTOU Vulnerability</a>.</p>

<p>If <code>src</code> is the path to a single file or directory and <code>dest</code> does not exist, moves <code>src</code> to <code>dest</code>:</p>

<pre class="ruby"><span class="ruby-identifier">tree</span>(<span class="ruby-string">&#39;src0&#39;</span>)
<span class="ruby-comment"># =&gt; src0</span>
<span class="ruby-comment">#    |-- src0.txt</span>
<span class="ruby-comment">#    `-- src1.txt</span>
<span class="ruby-constant">File</span>.<span class="ruby-identifier">exist?</span>(<span class="ruby-string">&#39;dest0&#39;</span>) <span class="ruby-comment"># =&gt; false</span>
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">mv</span>(<span class="ruby-string">&#39;src0&#39;</span>, <span class="ruby-string">&#39;dest0&#39;</span>)
<span class="ruby-constant">File</span>.<span class="ruby-identifier">exist?</span>(<span class="ruby-string">&#39;src0&#39;</span>)  <span class="ruby-comment"># =&gt; false</span>
<span class="ruby-identifier">tree</span>(<span class="ruby-string">&#39;dest0&#39;</span>)
<span class="ruby-comment"># =&gt; dest0</span>
<span class="ruby-comment">#    |-- src0.txt</span>
<span class="ruby-comment">#    `-- src1.txt</span>
</pre>

<p>If <code>src</code> is an array of paths to files and directories and <code>dest</code> is the path to a directory, copies from each path in the array to <code>dest</code>:</p>

<pre class="ruby"><span class="ruby-constant">File</span>.<span class="ruby-identifier">file?</span>(<span class="ruby-string">&#39;src1.txt&#39;</span>) <span class="ruby-comment"># =&gt; true</span>
<span class="ruby-identifier">tree</span>(<span class="ruby-string">&#39;src1&#39;</span>)
<span class="ruby-comment"># =&gt; src1</span>
<span class="ruby-comment">#    |-- src.dat</span>
<span class="ruby-comment">#    `-- src.txt</span>
<span class="ruby-constant">Dir</span>.<span class="ruby-identifier">empty?</span>(<span class="ruby-string">&#39;dest1&#39;</span>)    <span class="ruby-comment"># =&gt; true</span>
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">mv</span>([<span class="ruby-string">&#39;src1.txt&#39;</span>, <span class="ruby-string">&#39;src1&#39;</span>], <span class="ruby-string">&#39;dest1&#39;</span>)
<span class="ruby-identifier">tree</span>(<span class="ruby-string">&#39;dest1&#39;</span>)
<span class="ruby-comment"># =&gt; dest1</span>
<span class="ruby-comment">#    |-- src1</span>
<span class="ruby-comment">#    |   |-- src.dat</span>
<span class="ruby-comment">#    |   `-- src.txt</span>
<span class="ruby-comment">#    `-- src1.txt</span>
</pre>

<p>Keyword arguments:</p>
<ul><li>
<p><code>force: true</code> - if the move includes removing <code>src</code> (that is, if <code>src</code> and <code>dest</code> are on different file systems), ignores raised exceptions of StandardError and its descendants.</p>
</li><li>
<p><code>noop: true</code> - does not move files.</p>
</li><li>
<p><code>secure: true</code> - removes <code>src</code> securely; see details at <a href="FileUtils.html#method-c-remove_entry_secure"><code>FileUtils.remove_entry_secure</code></a>.</p>
</li><li>
<p><code>verbose: true</code> - prints an equivalent command:</p>

<pre class="ruby"><span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">mv</span>(<span class="ruby-string">&#39;src0&#39;</span>, <span class="ruby-string">&#39;dest0&#39;</span>, <span class="ruby-value">noop:</span> <span class="ruby-keyword">true</span>, <span class="ruby-value">verbose:</span> <span class="ruby-keyword">true</span>)
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">mv</span>([<span class="ruby-string">&#39;src1.txt&#39;</span>, <span class="ruby-string">&#39;src1&#39;</span>], <span class="ruby-string">&#39;dest1&#39;</span>, <span class="ruby-value">noop:</span> <span class="ruby-keyword">true</span>, <span class="ruby-value">verbose:</span> <span class="ruby-keyword">true</span>)
</pre>

<p>Output:</p>

<pre class="ruby"><span class="ruby-identifier">mv</span> <span class="ruby-identifier">src0</span> <span class="ruby-identifier">dest0</span>
<span class="ruby-identifier">mv</span> <span class="ruby-identifier">src1</span>.<span class="ruby-identifier">txt</span> <span class="ruby-identifier">src1</span> <span class="ruby-identifier">dest1</span>
</pre>
</li></ul>

                              <div class="method-source-code" id="mv-source">
            <pre><span class="ruby-comment"># File fileutils.rb, line 1157</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">mv</span>(<span class="ruby-identifier">src</span>, <span class="ruby-identifier">dest</span>, <span class="ruby-value">force:</span> <span class="ruby-keyword">nil</span>, <span class="ruby-value">noop:</span> <span class="ruby-keyword">nil</span>, <span class="ruby-value">verbose:</span> <span class="ruby-keyword">nil</span>, <span class="ruby-value">secure:</span> <span class="ruby-keyword">nil</span>)
  <span class="ruby-identifier">fu_output_message</span> <span class="ruby-node">&quot;mv#{force ? &#39; -f&#39; : &#39;&#39;} #{[src,dest].flatten.join &#39; &#39;}&quot;</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">verbose</span>
  <span class="ruby-keyword">return</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">noop</span>
  <span class="ruby-identifier">fu_each_src_dest</span>(<span class="ruby-identifier">src</span>, <span class="ruby-identifier">dest</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">s</span>, <span class="ruby-identifier">d</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">destent</span> = <span class="ruby-constant">Entry_</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">d</span>, <span class="ruby-keyword">nil</span>, <span class="ruby-keyword">true</span>)
    <span class="ruby-keyword">begin</span>
      <span class="ruby-keyword">if</span> <span class="ruby-identifier">destent</span>.<span class="ruby-identifier">exist?</span>
        <span class="ruby-keyword">if</span> <span class="ruby-identifier">destent</span>.<span class="ruby-identifier">directory?</span>
          <span class="ruby-identifier">raise</span> <span class="ruby-constant">Errno</span><span class="ruby-operator">::</span><span class="ruby-constant">EEXIST</span>, <span class="ruby-identifier">d</span>
        <span class="ruby-keyword">end</span>
      <span class="ruby-keyword">end</span>
      <span class="ruby-keyword">begin</span>
        <span class="ruby-constant">File</span>.<span class="ruby-identifier">rename</span> <span class="ruby-identifier">s</span>, <span class="ruby-identifier">d</span>
      <span class="ruby-keyword">rescue</span> <span class="ruby-constant">Errno</span><span class="ruby-operator">::</span><span class="ruby-constant">EXDEV</span>,
             <span class="ruby-constant">Errno</span><span class="ruby-operator">::</span><span class="ruby-constant">EPERM</span> <span class="ruby-comment"># move from unencrypted to encrypted dir (ext4)</span>
        <span class="ruby-identifier">copy_entry</span> <span class="ruby-identifier">s</span>, <span class="ruby-identifier">d</span>, <span class="ruby-keyword">true</span>
        <span class="ruby-keyword">if</span> <span class="ruby-identifier">secure</span>
          <span class="ruby-identifier">remove_entry_secure</span> <span class="ruby-identifier">s</span>, <span class="ruby-identifier">force</span>
        <span class="ruby-keyword">else</span>
          <span class="ruby-identifier">remove_entry</span> <span class="ruby-identifier">s</span>, <span class="ruby-identifier">force</span>
        <span class="ruby-keyword">end</span>
      <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">rescue</span> <span class="ruby-constant">SystemCallError</span>
      <span class="ruby-identifier">raise</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">force</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>

                            <div class="aliases">
                              Also aliased as: <a href="FileUtils.html#method-i-move">move</a>
                            </div>

                          </div>

                  <div id="method-c-options" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">options</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns an array of the string keyword names:</p>

<pre class="ruby"><span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">options</span>.<span class="ruby-identifier">take</span>(<span class="ruby-value">3</span>) <span class="ruby-comment"># =&gt; [&quot;noop&quot;, &quot;verbose&quot;, &quot;force&quot;]</span>
</pre>

                              <div class="method-source-code" id="options-source">
            <pre><span class="ruby-comment"># File fileutils.rb, line 2578</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">options</span>
  <span class="ruby-constant">OPT_TABLE</span>.<span class="ruby-identifier">values</span>.<span class="ruby-identifier">flatten</span>.<span class="ruby-identifier">uniq</span>.<span class="ruby-identifier">map</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">sym</span><span class="ruby-operator">|</span> <span class="ruby-identifier">sym</span>.<span class="ruby-identifier">to_s</span> }
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-options_of" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">options_of</span><span
                                class="method-args">(mid)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns an array of the string keyword name for method <code>mid</code>; the argument may be a string or a symbol:</p>

<pre class="ruby"><span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">options_of</span>(<span class="ruby-value">:rm</span>) <span class="ruby-comment"># =&gt; [&quot;force&quot;, &quot;noop&quot;, &quot;verbose&quot;]</span>
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">options_of</span>(<span class="ruby-string">&#39;mv&#39;</span>) <span class="ruby-comment"># =&gt; [&quot;force&quot;, &quot;noop&quot;, &quot;verbose&quot;, &quot;secure&quot;]</span>
</pre>

                              <div class="method-source-code" id="options_of-source">
            <pre><span class="ruby-comment"># File fileutils.rb, line 2599</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">options_of</span>(<span class="ruby-identifier">mid</span>)
  <span class="ruby-constant">OPT_TABLE</span>[<span class="ruby-identifier">mid</span>.<span class="ruby-identifier">to_s</span>].<span class="ruby-identifier">map</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">sym</span><span class="ruby-operator">|</span> <span class="ruby-identifier">sym</span>.<span class="ruby-identifier">to_s</span> }
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-pwd" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">pwd</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns a string containing the path to the current directory:</p>

<pre class="ruby"><span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">pwd</span> <span class="ruby-comment"># =&gt; &quot;/rdoc/fileutils&quot;</span>
</pre>

<p>Related: <a href="FileUtils.html#method-c-cd"><code>FileUtils.cd</code></a>.</p>

                              <div class="method-source-code" id="pwd-source">
            <pre><span class="ruby-comment"># File fileutils.rb, line 197</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">pwd</span>
  <span class="ruby-constant">Dir</span>.<span class="ruby-identifier">pwd</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>

                            <div class="aliases">
                              Also aliased as: <a href="FileUtils.html#method-i-getwd">getwd</a>
                            </div>

                          </div>

                  <div id="method-c-remove" class="method-detail method-alias">
                            <div class="method-heading">
                              <span class="method-name">remove</span><span
                                class="method-args">(list, force: nil, noop: nil, verbose: nil)</span>
                            </div>

                            <div class="method-description">
                              

                            </div>


                            <div class="aliases">
                              Alias for: <a href="FileUtils.html#method-i-rm">rm</a>
                            </div>
                          </div>

                  <div id="method-c-remove_dir" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">remove_dir</span><span
                                class="method-args">(path, force = false)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Recursively removes the directory entry given by <code>path</code>, which should be the entry for a regular file, a symbolic link, or a directory.</p>

<p>Argument <code>path</code> should be <a href="FileUtils.html#module-FileUtils-label-Path+Arguments">interpretable as a path</a>.</p>

<p>Optional argument <code>force</code> specifies whether to ignore raised exceptions of StandardError and its descendants.</p>

<p>Related: <a href="FileUtils.html#module-FileUtils-label-Deleting">methods for deleting</a>.</p>

                              <div class="method-source-code" id="remove_dir-source">
            <pre><span class="ruby-comment"># File fileutils.rb, line 1492</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">remove_dir</span>(<span class="ruby-identifier">path</span>, <span class="ruby-identifier">force</span> = <span class="ruby-keyword">false</span>)
  <span class="ruby-identifier">remove_entry</span> <span class="ruby-identifier">path</span>, <span class="ruby-identifier">force</span>   <span class="ruby-comment"># FIXME?? check if it is a directory</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-remove_entry" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">remove_entry</span><span
                                class="method-args">(path, force = false)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Removes the entry given by <code>path</code>, which should be the entry for a regular file, a symbolic link, or a directory.</p>

<p>Argument <code>path</code> should be <a href="FileUtils.html#module-FileUtils-label-Path+Arguments">interpretable as a path</a>.</p>

<p>Optional argument <code>force</code> specifies whether to ignore raised exceptions of StandardError and its descendants.</p>

<p>Related: <a href="FileUtils.html#method-c-remove_entry_secure"><code>FileUtils.remove_entry_secure</code></a>.</p>

                              <div class="method-source-code" id="remove_entry-source">
            <pre><span class="ruby-comment"># File fileutils.rb, line 1449</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">remove_entry</span>(<span class="ruby-identifier">path</span>, <span class="ruby-identifier">force</span> = <span class="ruby-keyword">false</span>)
  <span class="ruby-constant">Entry_</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">path</span>).<span class="ruby-identifier">postorder_traverse</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">ent</span><span class="ruby-operator">|</span>
    <span class="ruby-keyword">begin</span>
      <span class="ruby-identifier">ent</span>.<span class="ruby-identifier">remove</span>
    <span class="ruby-keyword">rescue</span>
      <span class="ruby-identifier">raise</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">force</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">rescue</span>
  <span class="ruby-identifier">raise</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">force</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-remove_entry_secure" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">remove_entry_secure</span><span
                                class="method-args">(path, force = false)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Securely removes the entry given by <code>path</code>, which should be the entry for a regular file, a symbolic link, or a directory.</p>

<p>Argument <code>path</code> should be <a href="FileUtils.html#module-FileUtils-label-Path+Arguments">interpretable as a path</a>.</p>

<p>Avoids a local vulnerability that can exist in certain circumstances; see <a href="FileUtils.html#module-FileUtils-label-Avoiding+the+TOCTTOU+Vulnerability">Avoiding the TOCTTOU Vulnerability</a>.</p>

<p>Optional argument <code>force</code> specifies whether to ignore raised exceptions of StandardError and its descendants.</p>

<p>Related: <a href="FileUtils.html#module-FileUtils-label-Deleting">methods for deleting</a>.</p>

                              <div class="method-source-code" id="remove_entry_secure-source">
            <pre><span class="ruby-comment"># File fileutils.rb, line 1351</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">remove_entry_secure</span>(<span class="ruby-identifier">path</span>, <span class="ruby-identifier">force</span> = <span class="ruby-keyword">false</span>)
  <span class="ruby-keyword">unless</span> <span class="ruby-identifier">fu_have_symlink?</span>
    <span class="ruby-identifier">remove_entry</span> <span class="ruby-identifier">path</span>, <span class="ruby-identifier">force</span>
    <span class="ruby-keyword">return</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-identifier">fullpath</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">expand_path</span>(<span class="ruby-identifier">path</span>)
  <span class="ruby-identifier">st</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">lstat</span>(<span class="ruby-identifier">fullpath</span>)
  <span class="ruby-keyword">unless</span> <span class="ruby-identifier">st</span>.<span class="ruby-identifier">directory?</span>
    <span class="ruby-constant">File</span>.<span class="ruby-identifier">unlink</span> <span class="ruby-identifier">fullpath</span>
    <span class="ruby-keyword">return</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-comment"># is a directory.</span>
  <span class="ruby-identifier">parent_st</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">stat</span>(<span class="ruby-constant">File</span>.<span class="ruby-identifier">dirname</span>(<span class="ruby-identifier">fullpath</span>))
  <span class="ruby-keyword">unless</span> <span class="ruby-identifier">parent_st</span>.<span class="ruby-identifier">world_writable?</span>
    <span class="ruby-identifier">remove_entry</span> <span class="ruby-identifier">path</span>, <span class="ruby-identifier">force</span>
    <span class="ruby-keyword">return</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">unless</span> <span class="ruby-identifier">parent_st</span>.<span class="ruby-identifier">sticky?</span>
    <span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-node">&quot;parent directory is world writable, FileUtils#remove_entry_secure does not work; abort: #{path.inspect} (parent directory mode #{&#39;%o&#39; % parent_st.mode})&quot;</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-comment"># freeze tree root</span>
  <span class="ruby-identifier">euid</span> = <span class="ruby-constant">Process</span>.<span class="ruby-identifier">euid</span>
  <span class="ruby-identifier">dot_file</span> = <span class="ruby-identifier">fullpath</span> <span class="ruby-operator">+</span> <span class="ruby-string">&quot;/.&quot;</span>
  <span class="ruby-keyword">begin</span>
    <span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-identifier">dot_file</span>) {<span class="ruby-operator">|</span><span class="ruby-identifier">f</span><span class="ruby-operator">|</span>
      <span class="ruby-keyword">unless</span> <span class="ruby-identifier">fu_stat_identical_entry?</span>(<span class="ruby-identifier">st</span>, <span class="ruby-identifier">f</span>.<span class="ruby-identifier">stat</span>)
        <span class="ruby-comment"># symlink (TOC-to-TOU attack?)</span>
        <span class="ruby-constant">File</span>.<span class="ruby-identifier">unlink</span> <span class="ruby-identifier">fullpath</span>
        <span class="ruby-keyword">return</span>
      <span class="ruby-keyword">end</span>
      <span class="ruby-identifier">f</span>.<span class="ruby-identifier">chown</span> <span class="ruby-identifier">euid</span>, <span class="ruby-value">-1</span>
      <span class="ruby-identifier">f</span>.<span class="ruby-identifier">chmod</span> <span class="ruby-value">0700</span>
    }
  <span class="ruby-keyword">rescue</span> <span class="ruby-constant">Errno</span><span class="ruby-operator">::</span><span class="ruby-constant">EISDIR</span> <span class="ruby-comment"># JRuby in non-native mode can&#39;t open files as dirs</span>
    <span class="ruby-constant">File</span>.<span class="ruby-identifier">lstat</span>(<span class="ruby-identifier">dot_file</span>).<span class="ruby-identifier">tap</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">fstat</span><span class="ruby-operator">|</span>
      <span class="ruby-keyword">unless</span> <span class="ruby-identifier">fu_stat_identical_entry?</span>(<span class="ruby-identifier">st</span>, <span class="ruby-identifier">fstat</span>)
        <span class="ruby-comment"># symlink (TOC-to-TOU attack?)</span>
        <span class="ruby-constant">File</span>.<span class="ruby-identifier">unlink</span> <span class="ruby-identifier">fullpath</span>
        <span class="ruby-keyword">return</span>
      <span class="ruby-keyword">end</span>
      <span class="ruby-constant">File</span>.<span class="ruby-identifier">chown</span> <span class="ruby-identifier">euid</span>, <span class="ruby-value">-1</span>, <span class="ruby-identifier">dot_file</span>
      <span class="ruby-constant">File</span>.<span class="ruby-identifier">chmod</span> <span class="ruby-value">0700</span>, <span class="ruby-identifier">dot_file</span>
    }
  <span class="ruby-keyword">end</span>

  <span class="ruby-keyword">unless</span> <span class="ruby-identifier">fu_stat_identical_entry?</span>(<span class="ruby-identifier">st</span>, <span class="ruby-constant">File</span>.<span class="ruby-identifier">lstat</span>(<span class="ruby-identifier">fullpath</span>))
    <span class="ruby-comment"># TOC-to-TOU attack?</span>
    <span class="ruby-constant">File</span>.<span class="ruby-identifier">unlink</span> <span class="ruby-identifier">fullpath</span>
    <span class="ruby-keyword">return</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-comment"># ---- tree root is frozen ----</span>
  <span class="ruby-identifier">root</span> = <span class="ruby-constant">Entry_</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">path</span>)
  <span class="ruby-identifier">root</span>.<span class="ruby-identifier">preorder_traverse</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">ent</span><span class="ruby-operator">|</span>
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">ent</span>.<span class="ruby-identifier">directory?</span>
      <span class="ruby-identifier">ent</span>.<span class="ruby-identifier">chown</span> <span class="ruby-identifier">euid</span>, <span class="ruby-value">-1</span>
      <span class="ruby-identifier">ent</span>.<span class="ruby-identifier">chmod</span> <span class="ruby-value">0700</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-identifier">root</span>.<span class="ruby-identifier">postorder_traverse</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">ent</span><span class="ruby-operator">|</span>
    <span class="ruby-keyword">begin</span>
      <span class="ruby-identifier">ent</span>.<span class="ruby-identifier">remove</span>
    <span class="ruby-keyword">rescue</span>
      <span class="ruby-identifier">raise</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">force</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">rescue</span>
  <span class="ruby-identifier">raise</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">force</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-remove_file" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">remove_file</span><span
                                class="method-args">(path, force = false)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Removes the file entry given by <code>path</code>, which should be the entry for a regular file or a symbolic link.</p>

<p>Argument <code>path</code> should be <a href="FileUtils.html#module-FileUtils-label-Path+Arguments">interpretable as a path</a>.</p>

<p>Optional argument <code>force</code> specifies whether to ignore raised exceptions of StandardError and its descendants.</p>

<p>Related: <a href="FileUtils.html#module-FileUtils-label-Deleting">methods for deleting</a>.</p>

                              <div class="method-source-code" id="remove_file-source">
            <pre><span class="ruby-comment"># File fileutils.rb, line 1473</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">remove_file</span>(<span class="ruby-identifier">path</span>, <span class="ruby-identifier">force</span> = <span class="ruby-keyword">false</span>)
  <span class="ruby-constant">Entry_</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">path</span>).<span class="ruby-identifier">remove_file</span>
<span class="ruby-keyword">rescue</span>
  <span class="ruby-identifier">raise</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">force</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-rm" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">rm</span><span
                                class="method-args">(list, force: nil, noop: nil, verbose: nil)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Removes entries at the paths in the given <code>list</code> (a single path or an array of paths) returns <code>list</code>, if it is an array, <code>[list]</code> otherwise.</p>

<p>Argument <code>list</code> or its elements should be <a href="FileUtils.html#module-FileUtils-label-Path+Arguments">interpretable as paths</a>.</p>

<p>With no keyword arguments, removes files at the paths given in <code>list</code>:</p>

<pre class="ruby"><span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">touch</span>([<span class="ruby-string">&#39;src0.txt&#39;</span>, <span class="ruby-string">&#39;src0.dat&#39;</span>])
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">rm</span>([<span class="ruby-string">&#39;src0.dat&#39;</span>, <span class="ruby-string">&#39;src0.txt&#39;</span>]) <span class="ruby-comment"># =&gt; [&quot;src0.dat&quot;, &quot;src0.txt&quot;]</span>
</pre>

<p>Keyword arguments:</p>
<ul><li>
<p><code>force: true</code> - ignores raised exceptions of StandardError and its descendants.</p>
</li><li>
<p><code>noop: true</code> - does not remove files; returns <code>nil</code>.</p>
</li><li>
<p><code>verbose: true</code> - prints an equivalent command:</p>

<pre class="ruby"><span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">rm</span>([<span class="ruby-string">&#39;src0.dat&#39;</span>, <span class="ruby-string">&#39;src0.txt&#39;</span>], <span class="ruby-value">noop:</span> <span class="ruby-keyword">true</span>, <span class="ruby-value">verbose:</span> <span class="ruby-keyword">true</span>)
</pre>

<p>Output:</p>

<pre class="ruby"><span class="ruby-identifier">rm</span> <span class="ruby-identifier">src0</span>.<span class="ruby-identifier">dat</span> <span class="ruby-identifier">src0</span>.<span class="ruby-identifier">txt</span>
</pre>
</li></ul>

<p>Related: <a href="FileUtils.html#module-FileUtils-label-Deleting">methods for deleting</a>.</p>

                              <div class="method-source-code" id="rm-source">
            <pre><span class="ruby-comment"># File fileutils.rb, line 1216</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">rm</span>(<span class="ruby-identifier">list</span>, <span class="ruby-value">force:</span> <span class="ruby-keyword">nil</span>, <span class="ruby-value">noop:</span> <span class="ruby-keyword">nil</span>, <span class="ruby-value">verbose:</span> <span class="ruby-keyword">nil</span>)
  <span class="ruby-identifier">list</span> = <span class="ruby-identifier">fu_list</span>(<span class="ruby-identifier">list</span>)
  <span class="ruby-identifier">fu_output_message</span> <span class="ruby-node">&quot;rm#{force ? &#39; -f&#39; : &#39;&#39;} #{list.join &#39; &#39;}&quot;</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">verbose</span>
  <span class="ruby-keyword">return</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">noop</span>

  <span class="ruby-identifier">list</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">path</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">remove_file</span> <span class="ruby-identifier">path</span>, <span class="ruby-identifier">force</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>

                            <div class="aliases">
                              Also aliased as: <a href="FileUtils.html#method-i-remove">remove</a>
                            </div>

                          </div>

                  <div id="method-c-rm_f" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">rm_f</span><span
                                class="method-args">(list, noop: nil, verbose: nil)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Equivalent to:</p>

<pre class="ruby"><span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">rm</span>(<span class="ruby-identifier">list</span>, <span class="ruby-value">force:</span> <span class="ruby-keyword">true</span>, <span class="ruby-operator">**</span><span class="ruby-identifier">kwargs</span>)
</pre>

<p>Argument <code>list</code> (a single path or an array of paths) should be <a href="FileUtils.html#module-FileUtils-label-Path+Arguments">interpretable as paths</a>.</p>

<p>See <a href="FileUtils.html#method-c-rm"><code>FileUtils.rm</code></a> for keyword arguments.</p>

<p>Related: <a href="FileUtils.html#module-FileUtils-label-Deleting">methods for deleting</a>.</p>

                              <div class="method-source-code" id="rm_f-source">
            <pre><span class="ruby-comment"># File fileutils.rb, line 1241</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">rm_f</span>(<span class="ruby-identifier">list</span>, <span class="ruby-value">noop:</span> <span class="ruby-keyword">nil</span>, <span class="ruby-value">verbose:</span> <span class="ruby-keyword">nil</span>)
  <span class="ruby-identifier">rm</span> <span class="ruby-identifier">list</span>, <span class="ruby-value">force:</span> <span class="ruby-keyword">true</span>, <span class="ruby-value">noop:</span> <span class="ruby-identifier">noop</span>, <span class="ruby-value">verbose:</span> <span class="ruby-identifier">verbose</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>

                            <div class="aliases">
                              Also aliased as: <a href="FileUtils.html#method-i-safe_unlink">safe_unlink</a>
                            </div>

                          </div>

                  <div id="method-c-rm_r" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">rm_r</span><span
                                class="method-args">(list, force: nil, noop: nil, verbose: nil, secure: nil)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Removes entries at the paths in the given <code>list</code> (a single path or an array of paths); returns <code>list</code>, if it is an array, <code>[list]</code> otherwise.</p>

<p>Argument <code>list</code> or its elements should be <a href="FileUtils.html#module-FileUtils-label-Path+Arguments">interpretable as paths</a>.</p>

<p>May cause a local vulnerability if not called with keyword argument <code>secure: true</code>; see <a href="FileUtils.html#module-FileUtils-label-Avoiding+the+TOCTTOU+Vulnerability">Avoiding the TOCTTOU Vulnerability</a>.</p>

<p>For each file path, removes the file at that path:</p>

<pre class="ruby"><span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">touch</span>([<span class="ruby-string">&#39;src0.txt&#39;</span>, <span class="ruby-string">&#39;src0.dat&#39;</span>])
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">rm_r</span>([<span class="ruby-string">&#39;src0.dat&#39;</span>, <span class="ruby-string">&#39;src0.txt&#39;</span>])
<span class="ruby-constant">File</span>.<span class="ruby-identifier">exist?</span>(<span class="ruby-string">&#39;src0.txt&#39;</span>) <span class="ruby-comment"># =&gt; false</span>
<span class="ruby-constant">File</span>.<span class="ruby-identifier">exist?</span>(<span class="ruby-string">&#39;src0.dat&#39;</span>) <span class="ruby-comment"># =&gt; false</span>
</pre>

<p>For each directory path, recursively removes files and directories:</p>

<pre class="ruby"><span class="ruby-identifier">tree</span>(<span class="ruby-string">&#39;src1&#39;</span>)
<span class="ruby-comment"># =&gt; src1</span>
<span class="ruby-comment">#    |-- dir0</span>
<span class="ruby-comment">#    |   |-- src0.txt</span>
<span class="ruby-comment">#    |   `-- src1.txt</span>
<span class="ruby-comment">#    `-- dir1</span>
<span class="ruby-comment">#        |-- src2.txt</span>
<span class="ruby-comment">#        `-- src3.txt</span>
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">rm_r</span>(<span class="ruby-string">&#39;src1&#39;</span>)
<span class="ruby-constant">File</span>.<span class="ruby-identifier">exist?</span>(<span class="ruby-string">&#39;src1&#39;</span>) <span class="ruby-comment"># =&gt; false</span>
</pre>

<p>Keyword arguments:</p>
<ul><li>
<p><code>force: true</code> - ignores raised exceptions of StandardError and its descendants.</p>
</li><li>
<p><code>noop: true</code> - does not remove entries; returns <code>nil</code>.</p>
</li><li>
<p><code>secure: true</code> - removes <code>src</code> securely; see details at <a href="FileUtils.html#method-c-remove_entry_secure"><code>FileUtils.remove_entry_secure</code></a>.</p>
</li><li>
<p><code>verbose: true</code> - prints an equivalent command:</p>

<pre class="ruby"><span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">rm_r</span>([<span class="ruby-string">&#39;src0.dat&#39;</span>, <span class="ruby-string">&#39;src0.txt&#39;</span>], <span class="ruby-value">noop:</span> <span class="ruby-keyword">true</span>, <span class="ruby-value">verbose:</span> <span class="ruby-keyword">true</span>)
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">rm_r</span>(<span class="ruby-string">&#39;src1&#39;</span>, <span class="ruby-value">noop:</span> <span class="ruby-keyword">true</span>, <span class="ruby-value">verbose:</span> <span class="ruby-keyword">true</span>)
</pre>

<p>Output:</p>

<pre>rm -r src0.dat src0.txt
rm -r src1</pre>
</li></ul>

<p>Related: <a href="FileUtils.html#module-FileUtils-label-Deleting">methods for deleting</a>.</p>

                              <div class="method-source-code" id="rm_r-source">
            <pre><span class="ruby-comment"># File fileutils.rb, line 1299</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">rm_r</span>(<span class="ruby-identifier">list</span>, <span class="ruby-value">force:</span> <span class="ruby-keyword">nil</span>, <span class="ruby-value">noop:</span> <span class="ruby-keyword">nil</span>, <span class="ruby-value">verbose:</span> <span class="ruby-keyword">nil</span>, <span class="ruby-value">secure:</span> <span class="ruby-keyword">nil</span>)
  <span class="ruby-identifier">list</span> = <span class="ruby-identifier">fu_list</span>(<span class="ruby-identifier">list</span>)
  <span class="ruby-identifier">fu_output_message</span> <span class="ruby-node">&quot;rm -r#{force ? &#39;f&#39; : &#39;&#39;} #{list.join &#39; &#39;}&quot;</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">verbose</span>
  <span class="ruby-keyword">return</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">noop</span>
  <span class="ruby-identifier">list</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">path</span><span class="ruby-operator">|</span>
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">secure</span>
      <span class="ruby-identifier">remove_entry_secure</span> <span class="ruby-identifier">path</span>, <span class="ruby-identifier">force</span>
    <span class="ruby-keyword">else</span>
      <span class="ruby-identifier">remove_entry</span> <span class="ruby-identifier">path</span>, <span class="ruby-identifier">force</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-rm_rf" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">rm_rf</span><span
                                class="method-args">(list, noop: nil, verbose: nil, secure: nil)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Equivalent to:</p>

<pre class="ruby"><span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">rm_r</span>(<span class="ruby-identifier">list</span>, <span class="ruby-value">force:</span> <span class="ruby-keyword">true</span>, <span class="ruby-operator">**</span><span class="ruby-identifier">kwargs</span>)
</pre>

<p>Argument <code>list</code> or its elements should be <a href="FileUtils.html#module-FileUtils-label-Path+Arguments">interpretable as paths</a>.</p>

<p>May cause a local vulnerability if not called with keyword argument <code>secure: true</code>; see <a href="FileUtils.html#module-FileUtils-label-Avoiding+the+TOCTTOU+Vulnerability">Avoiding the TOCTTOU Vulnerability</a>.</p>

<p>See <a href="FileUtils.html#method-c-rm_r"><code>FileUtils.rm_r</code></a> for keyword arguments.</p>

<p>Related: <a href="FileUtils.html#module-FileUtils-label-Deleting">methods for deleting</a>.</p>

                              <div class="method-source-code" id="rm_rf-source">
            <pre><span class="ruby-comment"># File fileutils.rb, line 1328</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">rm_rf</span>(<span class="ruby-identifier">list</span>, <span class="ruby-value">noop:</span> <span class="ruby-keyword">nil</span>, <span class="ruby-value">verbose:</span> <span class="ruby-keyword">nil</span>, <span class="ruby-value">secure:</span> <span class="ruby-keyword">nil</span>)
  <span class="ruby-identifier">rm_r</span> <span class="ruby-identifier">list</span>, <span class="ruby-value">force:</span> <span class="ruby-keyword">true</span>, <span class="ruby-value">noop:</span> <span class="ruby-identifier">noop</span>, <span class="ruby-value">verbose:</span> <span class="ruby-identifier">verbose</span>, <span class="ruby-value">secure:</span> <span class="ruby-identifier">secure</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>

                            <div class="aliases">
                              Also aliased as: <a href="FileUtils.html#method-i-rmtree">rmtree</a>
                            </div>

                          </div>

                  <div id="method-c-rmdir" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">rmdir</span><span
                                class="method-args">(list, parents: nil, noop: nil, verbose: nil)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Removes directories at the paths in the given <code>list</code> (a single path or an array of paths); returns <code>list</code>, if it is an array, <code>[list]</code> otherwise.</p>

<p>Argument <code>list</code> or its elements should be <a href="FileUtils.html#module-FileUtils-label-Path+Arguments">interpretable as paths</a>.</p>

<p>With no keyword arguments, removes the directory at each <code>path</code> in <code>list</code>, by calling: <code>Dir.rmdir(path)</code>; see Dir.rmdir:</p>

<pre class="ruby"><span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">rmdir</span>(<span class="ruby-node">%w[tmp0/tmp1 tmp2/tmp3]</span>) <span class="ruby-comment"># =&gt; [&quot;tmp0/tmp1&quot;, &quot;tmp2/tmp3&quot;]</span>
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">rmdir</span>(<span class="ruby-string">&#39;tmp4/tmp5&#39;</span>)             <span class="ruby-comment"># =&gt; [&quot;tmp4/tmp5&quot;]</span>
</pre>

<p>Keyword arguments:</p>
<ul><li>
<p><code>parents: true</code> - removes successive ancestor directories if empty.</p>
</li><li>
<p><code>noop: true</code> - does not remove directories.</p>
</li><li>
<p><code>verbose: true</code> - prints an equivalent command:</p>

<pre class="ruby"><span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">rmdir</span>(<span class="ruby-node">%w[tmp0/tmp1 tmp2/tmp3]</span>, <span class="ruby-value">parents:</span> <span class="ruby-keyword">true</span>, <span class="ruby-value">verbose:</span> <span class="ruby-keyword">true</span>)
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">rmdir</span>(<span class="ruby-string">&#39;tmp4/tmp5&#39;</span>, <span class="ruby-value">parents:</span> <span class="ruby-keyword">true</span>, <span class="ruby-value">verbose:</span> <span class="ruby-keyword">true</span>)
</pre>

<p>Output:</p>

<pre>rmdir -p tmp0/tmp1 tmp2/tmp3
rmdir -p tmp4/tmp5</pre>
</li></ul>

<p>Raises an exception if a directory does not exist or if for any reason a directory cannot be removed.</p>

<p>Related: <a href="FileUtils.html#module-FileUtils-label-Deleting">methods for deleting</a>.</p>

                              <div class="method-source-code" id="rmdir-source">
            <pre><span class="ruby-comment"># File fileutils.rb, line 442</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">rmdir</span>(<span class="ruby-identifier">list</span>, <span class="ruby-value">parents:</span> <span class="ruby-keyword">nil</span>, <span class="ruby-value">noop:</span> <span class="ruby-keyword">nil</span>, <span class="ruby-value">verbose:</span> <span class="ruby-keyword">nil</span>)
  <span class="ruby-identifier">list</span> = <span class="ruby-identifier">fu_list</span>(<span class="ruby-identifier">list</span>)
  <span class="ruby-identifier">fu_output_message</span> <span class="ruby-node">&quot;rmdir #{parents ? &#39;-p &#39; : &#39;&#39;}#{list.join &#39; &#39;}&quot;</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">verbose</span>
  <span class="ruby-keyword">return</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">noop</span>
  <span class="ruby-identifier">list</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">dir</span><span class="ruby-operator">|</span>
    <span class="ruby-constant">Dir</span>.<span class="ruby-identifier">rmdir</span>(<span class="ruby-identifier">dir</span> = <span class="ruby-identifier">remove_trailing_slash</span>(<span class="ruby-identifier">dir</span>))
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">parents</span>
      <span class="ruby-keyword">begin</span>
        <span class="ruby-keyword">until</span> (<span class="ruby-identifier">parent</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">dirname</span>(<span class="ruby-identifier">dir</span>)) <span class="ruby-operator">==</span> <span class="ruby-string">&#39;.&#39;</span> <span class="ruby-keyword">or</span> <span class="ruby-identifier">parent</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">dir</span>
          <span class="ruby-identifier">dir</span> = <span class="ruby-identifier">parent</span>
          <span class="ruby-constant">Dir</span>.<span class="ruby-identifier">rmdir</span>(<span class="ruby-identifier">dir</span>)
        <span class="ruby-keyword">end</span>
      <span class="ruby-keyword">rescue</span> <span class="ruby-constant">Errno</span><span class="ruby-operator">::</span><span class="ruby-constant">ENOTEMPTY</span>, <span class="ruby-constant">Errno</span><span class="ruby-operator">::</span><span class="ruby-constant">EEXIST</span>, <span class="ruby-constant">Errno</span><span class="ruby-operator">::</span><span class="ruby-constant">ENOENT</span>
      <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-rmtree" class="method-detail method-alias">
                            <div class="method-heading">
                              <span class="method-name">rmtree</span><span
                                class="method-args">(list, noop: nil, verbose: nil, secure: nil)</span>
                            </div>

                            <div class="method-description">
                              

                            </div>


                            <div class="aliases">
                              Alias for: <a href="FileUtils.html#method-i-rm_rf">rm_rf</a>
                            </div>
                          </div>

                  <div id="method-c-safe_unlink" class="method-detail method-alias">
                            <div class="method-heading">
                              <span class="method-name">safe_unlink</span><span
                                class="method-args">(list, noop: nil, verbose: nil)</span>
                            </div>

                            <div class="method-description">
                              

                            </div>


                            <div class="aliases">
                              Alias for: <a href="FileUtils.html#method-i-rm_f">rm_f</a>
                            </div>
                          </div>

                  <div id="method-c-symlink" class="method-detail method-alias">
                            <div class="method-heading">
                              <span class="method-name">symlink</span><span
                                class="method-args">(src, dest, force: nil, relative: false, target_directory: true, noop: nil, verbose: nil)</span>
                            </div>

                            <div class="method-description">
                              

                            </div>


                            <div class="aliases">
                              Alias for: <a href="FileUtils.html#method-i-ln_s">ln_s</a>
                            </div>
                          </div>

                  <div id="method-c-touch" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">touch</span><span
                                class="method-args">(list, noop: nil, verbose: nil, mtime: nil, nocreate: nil)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Updates modification times (mtime) and access times (atime) of the entries given by the paths in <code>list</code> (a single path or an array of paths); returns <code>list</code> if it is an array, <code>[list]</code> otherwise.</p>

<p>By default, creates an empty file for any path to a non-existent entry; use keyword argument <code>nocreate</code> to raise an exception instead.</p>

<p>Argument <code>list</code> or its elements should be <a href="FileUtils.html#module-FileUtils-label-Path+Arguments">interpretable as paths</a>.</p>

<p>Examples:</p>

<pre class="ruby"><span class="ruby-comment"># Single path.</span>
<span class="ruby-identifier">f</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">new</span>(<span class="ruby-string">&#39;src0.txt&#39;</span>) <span class="ruby-comment"># Existing file.</span>
<span class="ruby-identifier">f</span>.<span class="ruby-identifier">atime</span> <span class="ruby-comment"># =&gt; 2022-06-10 11:11:21.200277 -0700</span>
<span class="ruby-identifier">f</span>.<span class="ruby-identifier">mtime</span> <span class="ruby-comment"># =&gt; 2022-06-10 11:11:21.200277 -0700</span>
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">touch</span>(<span class="ruby-string">&#39;src0.txt&#39;</span>)
<span class="ruby-identifier">f</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">new</span>(<span class="ruby-string">&#39;src0.txt&#39;</span>)
<span class="ruby-identifier">f</span>.<span class="ruby-identifier">atime</span> <span class="ruby-comment"># =&gt; 2022-06-11 08:28:09.8185343 -0700</span>
<span class="ruby-identifier">f</span>.<span class="ruby-identifier">mtime</span> <span class="ruby-comment"># =&gt; 2022-06-11 08:28:09.8185343 -0700</span>

<span class="ruby-comment"># Array of paths.</span>
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">touch</span>([<span class="ruby-string">&#39;src0.txt&#39;</span>, <span class="ruby-string">&#39;src0.dat&#39;</span>])
</pre>

<p>Keyword arguments:</p>
<ul><li>
<p><code>mtime: <em>time</em></code> - sets the entry’s mtime to the given time, instead of the current time.</p>
</li><li>
<p><code>nocreate: true</code> - raises an exception if the entry does not exist.</p>
</li><li>
<p><code>noop: true</code> - does not touch entries; returns <code>nil</code>.</p>
</li><li>
<p><code>verbose: true</code> - prints an equivalent command:</p>

<pre class="ruby"><span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">touch</span>(<span class="ruby-string">&#39;src0.txt&#39;</span>, <span class="ruby-value">noop:</span> <span class="ruby-keyword">true</span>, <span class="ruby-value">verbose:</span> <span class="ruby-keyword">true</span>)
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">touch</span>([<span class="ruby-string">&#39;src0.txt&#39;</span>, <span class="ruby-string">&#39;src0.dat&#39;</span>], <span class="ruby-value">noop:</span> <span class="ruby-keyword">true</span>, <span class="ruby-value">verbose:</span> <span class="ruby-keyword">true</span>)
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">touch</span>(<span class="ruby-identifier">path</span>, <span class="ruby-value">noop:</span> <span class="ruby-keyword">true</span>, <span class="ruby-value">verbose:</span> <span class="ruby-keyword">true</span>)
</pre>

<p>Output:</p>

<pre class="ruby"><span class="ruby-identifier">touch</span> <span class="ruby-identifier">src0</span>.<span class="ruby-identifier">txt</span>
<span class="ruby-identifier">touch</span> <span class="ruby-identifier">src0</span>.<span class="ruby-identifier">txt</span> <span class="ruby-identifier">src0</span>.<span class="ruby-identifier">dat</span>
<span class="ruby-identifier">touch</span> <span class="ruby-identifier">src0</span>.<span class="ruby-identifier">txt</span>
</pre>
</li></ul>

<p>Related: <a href="FileUtils.html#method-c-uptodate-3F"><code>FileUtils.uptodate?</code></a>.</p>

                              <div class="method-source-code" id="touch-source">
            <pre><span class="ruby-comment"># File fileutils.rb, line 2006</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">touch</span>(<span class="ruby-identifier">list</span>, <span class="ruby-value">noop:</span> <span class="ruby-keyword">nil</span>, <span class="ruby-value">verbose:</span> <span class="ruby-keyword">nil</span>, <span class="ruby-value">mtime:</span> <span class="ruby-keyword">nil</span>, <span class="ruby-value">nocreate:</span> <span class="ruby-keyword">nil</span>)
  <span class="ruby-identifier">list</span> = <span class="ruby-identifier">fu_list</span>(<span class="ruby-identifier">list</span>)
  <span class="ruby-identifier">t</span> = <span class="ruby-identifier">mtime</span>
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">verbose</span>
    <span class="ruby-identifier">fu_output_message</span> <span class="ruby-node">&quot;touch #{nocreate ? &#39;-c &#39; : &#39;&#39;}#{t ? t.strftime(&#39;-t %Y%m%d%H%M.%S &#39;) : &#39;&#39;}#{list.join &#39; &#39;}&quot;</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">return</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">noop</span>
  <span class="ruby-identifier">list</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">path</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">created</span> = <span class="ruby-identifier">nocreate</span>
    <span class="ruby-keyword">begin</span>
      <span class="ruby-constant">File</span>.<span class="ruby-identifier">utime</span>(<span class="ruby-identifier">t</span>, <span class="ruby-identifier">t</span>, <span class="ruby-identifier">path</span>)
    <span class="ruby-keyword">rescue</span> <span class="ruby-constant">Errno</span><span class="ruby-operator">::</span><span class="ruby-constant">ENOENT</span>
      <span class="ruby-identifier">raise</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">created</span>
      <span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-identifier">path</span>, <span class="ruby-string">&#39;a&#39;</span>) {
        ;
      }
      <span class="ruby-identifier">created</span> = <span class="ruby-keyword">true</span>
      <span class="ruby-keyword">retry</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">t</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-uptodate-3F" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">uptodate?</span><span
                                class="method-args">(new, old_list)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns <code>true</code> if the file at path <code>new</code> is newer than all the files at paths in array <code>old_list</code>; <code>false</code> otherwise.</p>

<p>Argument <code>new</code> and the elements of <code>old_list</code> should be <a href="FileUtils.html#module-FileUtils-label-Path+Arguments">interpretable as paths</a>:</p>

<pre class="ruby"><span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">uptodate?</span>(<span class="ruby-string">&#39;Rakefile&#39;</span>, [<span class="ruby-string">&#39;Gemfile&#39;</span>, <span class="ruby-string">&#39;README.md&#39;</span>]) <span class="ruby-comment"># =&gt; true</span>
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">uptodate?</span>(<span class="ruby-string">&#39;Gemfile&#39;</span>, [<span class="ruby-string">&#39;Rakefile&#39;</span>, <span class="ruby-string">&#39;README.md&#39;</span>]) <span class="ruby-comment"># =&gt; false</span>
</pre>

<p>A non-existent file is considered to be infinitely old.</p>

<p>Related: <a href="FileUtils.html#method-c-touch"><code>FileUtils.touch</code></a>.</p>

                              <div class="method-source-code" id="uptodate-3F-source">
            <pre><span class="ruby-comment"># File fileutils.rb, line 264</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">uptodate?</span>(<span class="ruby-identifier">new</span>, <span class="ruby-identifier">old_list</span>)
  <span class="ruby-keyword">return</span> <span class="ruby-keyword">false</span> <span class="ruby-keyword">unless</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">exist?</span>(<span class="ruby-identifier">new</span>)
  <span class="ruby-identifier">new_time</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">mtime</span>(<span class="ruby-identifier">new</span>)
  <span class="ruby-identifier">old_list</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">old</span><span class="ruby-operator">|</span>
    <span class="ruby-keyword">if</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">exist?</span>(<span class="ruby-identifier">old</span>)
      <span class="ruby-keyword">return</span> <span class="ruby-keyword">false</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">new_time</span> <span class="ruby-operator">&gt;</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">mtime</span>(<span class="ruby-identifier">old</span>)
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">true</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                          </section>

                <section id="private-instance-5Buntitled-5D-method-details" class="method-section">
                <header>
                <h3>Private Instance Methods</h3>
                </header>

                  <div id="method-i-cd" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">cd</span><span
                                class="method-args">(dir, verbose: nil) { |dir| ... }</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Changes the working directory to the given <code>dir</code>, which should be <a href="FileUtils.html#module-FileUtils-label-Path+Arguments">interpretable as a path</a>:</p>

<p>With no block given, changes the current directory to the directory at <code>dir</code>; returns zero:</p>

<pre class="ruby"><span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">pwd</span> <span class="ruby-comment"># =&gt; &quot;/rdoc/fileutils&quot;</span>
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">cd</span>(<span class="ruby-string">&#39;..&#39;</span>)
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">pwd</span> <span class="ruby-comment"># =&gt; &quot;/rdoc&quot;</span>
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">cd</span>(<span class="ruby-string">&#39;fileutils&#39;</span>)
</pre>

<p>With a block given, changes the current directory to the directory at <code>dir</code>, calls the block with argument <code>dir</code>, and restores the original current directory; returns the block’s value:</p>

<pre class="ruby"><span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">pwd</span>                                     <span class="ruby-comment"># =&gt; &quot;/rdoc/fileutils&quot;</span>
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">cd</span>(<span class="ruby-string">&#39;..&#39;</span>) { <span class="ruby-operator">|</span><span class="ruby-identifier">arg</span><span class="ruby-operator">|</span> [<span class="ruby-identifier">arg</span>, <span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">pwd</span>] } <span class="ruby-comment"># =&gt; [&quot;..&quot;, &quot;/rdoc&quot;]</span>
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">pwd</span>                                     <span class="ruby-comment"># =&gt; &quot;/rdoc/fileutils&quot;</span>
</pre>

<p>Keyword arguments:</p>
<ul><li>
<p><code>verbose: true</code> - prints an equivalent command:</p>

<pre class="ruby"><span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">cd</span>(<span class="ruby-string">&#39;..&#39;</span>)
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">cd</span>(<span class="ruby-string">&#39;fileutils&#39;</span>)
</pre>

<p>Output:</p>

<pre>cd ..
cd fileutils</pre>
</li></ul>

<p>Related: <a href="FileUtils.html#method-c-pwd"><code>FileUtils.pwd</code></a>.</p>

                              <div class="method-source-code" id="cd-source">
            <pre><span class="ruby-comment"># File fileutils.rb, line 238</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">cd</span>(<span class="ruby-identifier">dir</span>, <span class="ruby-value">verbose:</span> <span class="ruby-keyword">nil</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>) <span class="ruby-comment"># :yield: dir</span>
  <span class="ruby-identifier">fu_output_message</span> <span class="ruby-node">&quot;cd #{dir}&quot;</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">verbose</span>
  <span class="ruby-identifier">result</span> = <span class="ruby-constant">Dir</span>.<span class="ruby-identifier">chdir</span>(<span class="ruby-identifier">dir</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
  <span class="ruby-identifier">fu_output_message</span> <span class="ruby-string">&#39;cd -&#39;</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">verbose</span> <span class="ruby-keyword">and</span> <span class="ruby-identifier">block</span>
  <span class="ruby-identifier">result</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>

                            <div class="aliases">
                              Also aliased as: <a href="FileUtils.html#method-i-chdir">chdir</a>
                            </div>

                          </div>

                  <div id="method-i-chdir" class="method-detail method-alias">
                            <div class="method-heading">
                              <span class="method-name">chdir</span><span
                                class="method-args">(dir, verbose: nil)</span>
                            </div>

                            <div class="method-description">
                              

                            </div>


                            <div class="aliases">
                              Alias for: <a href="FileUtils.html#method-i-cd">cd</a>
                            </div>
                          </div>

                  <div id="method-i-chmod" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">chmod</span><span
                                class="method-args">(mode, list, noop: nil, verbose: nil)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Changes permissions on the entries at the paths given in <code>list</code> (a single path or an array of paths) to the permissions given by <code>mode</code>; returns <code>list</code> if it is an array, <code>[list]</code> otherwise:</p>
<ul><li>
<p>Modifies each entry that is a regular file using File.chmod.</p>
</li><li>
<p>Modifies each entry that is a symbolic link using File.lchmod.</p>
</li></ul>

<p>Argument <code>list</code> or its elements should be <a href="FileUtils.html#module-FileUtils-label-Path+Arguments">interpretable as paths</a>.</p>

<p>Argument <code>mode</code> may be either an integer or a string:</p>
<ul><li>
<p>Integer <code>mode</code>: represents the permission bits to be set:</p>

<pre class="ruby"><span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">chmod</span>(<span class="ruby-value">0755</span>, <span class="ruby-string">&#39;src0.txt&#39;</span>)
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">chmod</span>(<span class="ruby-value">0644</span>, [<span class="ruby-string">&#39;src0.txt&#39;</span>, <span class="ruby-string">&#39;src0.dat&#39;</span>])
</pre>
</li><li>
<p>String <code>mode</code>: represents the permissions to be set:</p>

<p>The string is of the form <code>[targets][[operator][perms[,perms]]</code>, where:</p>
<ul><li>
<p><code>targets</code> may be any combination of these letters:</p>
<ul><li>
<p><code>&#39;u&#39;</code>: permissions apply to the file’s owner.</p>
</li><li>
<p><code>&#39;g&#39;</code>: permissions apply to users in the file’s group.</p>
</li><li>
<p><code>&#39;o&#39;</code>: permissions apply to other users not in the file’s group.</p>
</li><li>
<p><code>&#39;a&#39;</code> (the default): permissions apply to all users.</p>
</li></ul>
</li><li>
<p><code>operator</code> may be one of these letters:</p>
<ul><li>
<p><code>&#39;+&#39;</code>: adds permissions.</p>
</li><li>
<p><code>&#39;-&#39;</code>: removes permissions.</p>
</li><li>
<p><code>&#39;=&#39;</code>: sets (replaces) permissions.</p>
</li></ul>
</li><li>
<p><code>perms</code> (may be repeated, with separating commas) may be any combination of these letters:</p>
<ul><li>
<p><code>&#39;r&#39;</code>: Read.</p>
</li><li>
<p><code>&#39;w&#39;</code>: Write.</p>
</li><li>
<p><code>&#39;x&#39;</code>: Execute (search, for a directory).</p>
</li><li>
<p><code>&#39;X&#39;</code>: Search (for a directories only; must be used with <code>&#39;+&#39;</code>)</p>
</li><li>
<p><code>&#39;s&#39;</code>: Uid or gid.</p>
</li><li>
<p><code>&#39;t&#39;</code>: Sticky bit.</p>
</li></ul>
</li></ul>

<p>Examples:</p>

<pre class="ruby"><span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">chmod</span>(<span class="ruby-string">&#39;u=wrx,go=rx&#39;</span>, <span class="ruby-string">&#39;src1.txt&#39;</span>)
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">chmod</span>(<span class="ruby-string">&#39;u=wrx,go=rx&#39;</span>, <span class="ruby-string">&#39;/usr/bin/ruby&#39;</span>)
</pre>
</li></ul>

<p>Keyword arguments:</p>
<ul><li>
<p><code>noop: true</code> - does not change permissions; returns <code>nil</code>.</p>
</li><li>
<p><code>verbose: true</code> - prints an equivalent command:</p>

<pre class="ruby"><span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">chmod</span>(<span class="ruby-value">0755</span>, <span class="ruby-string">&#39;src0.txt&#39;</span>, <span class="ruby-value">noop:</span> <span class="ruby-keyword">true</span>, <span class="ruby-value">verbose:</span> <span class="ruby-keyword">true</span>)
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">chmod</span>(<span class="ruby-value">0644</span>, [<span class="ruby-string">&#39;src0.txt&#39;</span>, <span class="ruby-string">&#39;src0.dat&#39;</span>], <span class="ruby-value">noop:</span> <span class="ruby-keyword">true</span>, <span class="ruby-value">verbose:</span> <span class="ruby-keyword">true</span>)
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">chmod</span>(<span class="ruby-string">&#39;u=wrx,go=rx&#39;</span>, <span class="ruby-string">&#39;src1.txt&#39;</span>, <span class="ruby-value">noop:</span> <span class="ruby-keyword">true</span>, <span class="ruby-value">verbose:</span> <span class="ruby-keyword">true</span>)
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">chmod</span>(<span class="ruby-string">&#39;u=wrx,go=rx&#39;</span>, <span class="ruby-string">&#39;/usr/bin/ruby&#39;</span>, <span class="ruby-value">noop:</span> <span class="ruby-keyword">true</span>, <span class="ruby-value">verbose:</span> <span class="ruby-keyword">true</span>)
</pre>

<p>Output:</p>

<pre>chmod 755 src0.txt
chmod 644 src0.txt src0.dat
chmod u=wrx,go=rx src1.txt
chmod u=wrx,go=rx /usr/bin/ruby</pre>
</li></ul>

<p>Related: <a href="FileUtils.html#method-c-chmod_R"><code>FileUtils.chmod_R</code></a>.</p>

                              <div class="method-source-code" id="chmod-source">
            <pre><span class="ruby-comment"># File fileutils.rb, line 1803</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">chmod</span>(<span class="ruby-identifier">mode</span>, <span class="ruby-identifier">list</span>, <span class="ruby-value">noop:</span> <span class="ruby-keyword">nil</span>, <span class="ruby-value">verbose:</span> <span class="ruby-keyword">nil</span>)
  <span class="ruby-identifier">list</span> = <span class="ruby-identifier">fu_list</span>(<span class="ruby-identifier">list</span>)
  <span class="ruby-identifier">fu_output_message</span> <span class="ruby-identifier">sprintf</span>(<span class="ruby-string">&#39;chmod %s %s&#39;</span>, <span class="ruby-identifier">mode_to_s</span>(<span class="ruby-identifier">mode</span>), <span class="ruby-identifier">list</span>.<span class="ruby-identifier">join</span>(<span class="ruby-string">&#39; &#39;</span>)) <span class="ruby-keyword">if</span> <span class="ruby-identifier">verbose</span>
  <span class="ruby-keyword">return</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">noop</span>
  <span class="ruby-identifier">list</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">path</span><span class="ruby-operator">|</span>
    <span class="ruby-constant">Entry_</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">path</span>).<span class="ruby-identifier">chmod</span>(<span class="ruby-identifier">fu_mode</span>(<span class="ruby-identifier">mode</span>, <span class="ruby-identifier">path</span>))
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-chmod_R" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">chmod_R</span><span
                                class="method-args">(mode, list, noop: nil, verbose: nil, force: nil)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Like <a href="FileUtils.html#method-c-chmod"><code>FileUtils.chmod</code></a>, but changes permissions recursively.</p>

                              <div class="method-source-code" id="chmod_R-source">
            <pre><span class="ruby-comment"># File fileutils.rb, line 1815</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">chmod_R</span>(<span class="ruby-identifier">mode</span>, <span class="ruby-identifier">list</span>, <span class="ruby-value">noop:</span> <span class="ruby-keyword">nil</span>, <span class="ruby-value">verbose:</span> <span class="ruby-keyword">nil</span>, <span class="ruby-value">force:</span> <span class="ruby-keyword">nil</span>)
  <span class="ruby-identifier">list</span> = <span class="ruby-identifier">fu_list</span>(<span class="ruby-identifier">list</span>)
  <span class="ruby-identifier">fu_output_message</span> <span class="ruby-identifier">sprintf</span>(<span class="ruby-string">&#39;chmod -R%s %s %s&#39;</span>,
                            (<span class="ruby-identifier">force</span> <span class="ruby-operator">?</span> <span class="ruby-string">&#39;f&#39;</span> <span class="ruby-operator">:</span> <span class="ruby-string">&#39;&#39;</span>),
                            <span class="ruby-identifier">mode_to_s</span>(<span class="ruby-identifier">mode</span>), <span class="ruby-identifier">list</span>.<span class="ruby-identifier">join</span>(<span class="ruby-string">&#39; &#39;</span>)) <span class="ruby-keyword">if</span> <span class="ruby-identifier">verbose</span>
  <span class="ruby-keyword">return</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">noop</span>
  <span class="ruby-identifier">list</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">root</span><span class="ruby-operator">|</span>
    <span class="ruby-constant">Entry_</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">root</span>).<span class="ruby-identifier">traverse</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">ent</span><span class="ruby-operator">|</span>
      <span class="ruby-keyword">begin</span>
        <span class="ruby-identifier">ent</span>.<span class="ruby-identifier">chmod</span>(<span class="ruby-identifier">fu_mode</span>(<span class="ruby-identifier">mode</span>, <span class="ruby-identifier">ent</span>.<span class="ruby-identifier">path</span>))
      <span class="ruby-keyword">rescue</span>
        <span class="ruby-identifier">raise</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">force</span>
      <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-chown" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">chown</span><span
                                class="method-args">(user, group, list, noop: nil, verbose: nil)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Changes the owner and group on the entries at the paths given in <code>list</code> (a single path or an array of paths) to the given <code>user</code> and <code>group</code>; returns <code>list</code> if it is an array, <code>[list]</code> otherwise:</p>
<ul><li>
<p>Modifies each entry that is a regular file using File.chown.</p>
</li><li>
<p>Modifies each entry that is a symbolic link using File.lchown.</p>
</li></ul>

<p>Argument <code>list</code> or its elements should be <a href="FileUtils.html#module-FileUtils-label-Path+Arguments">interpretable as paths</a>.</p>

<p>User and group:</p>
<ul><li>
<p>Argument <code>user</code> may be a user name or a user id; if <code>nil</code> or <code>-1</code>, the user is not changed.</p>
</li><li>
<p>Argument <code>group</code> may be a group name or a group id; if <code>nil</code> or <code>-1</code>, the group is not changed.</p>
</li><li>
<p>The user must be a member of the group.</p>
</li></ul>

<p>Examples:</p>

<pre class="ruby"><span class="ruby-comment"># One path.</span>
<span class="ruby-comment"># User and group as string names.</span>
<span class="ruby-constant">File</span>.<span class="ruby-identifier">stat</span>(<span class="ruby-string">&#39;src0.txt&#39;</span>).<span class="ruby-identifier">uid</span> <span class="ruby-comment"># =&gt; 1004</span>
<span class="ruby-constant">File</span>.<span class="ruby-identifier">stat</span>(<span class="ruby-string">&#39;src0.txt&#39;</span>).<span class="ruby-identifier">gid</span> <span class="ruby-comment"># =&gt; 1004</span>
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">chown</span>(<span class="ruby-string">&#39;user2&#39;</span>, <span class="ruby-string">&#39;group1&#39;</span>, <span class="ruby-string">&#39;src0.txt&#39;</span>)
<span class="ruby-constant">File</span>.<span class="ruby-identifier">stat</span>(<span class="ruby-string">&#39;src0.txt&#39;</span>).<span class="ruby-identifier">uid</span> <span class="ruby-comment"># =&gt; 1006</span>
<span class="ruby-constant">File</span>.<span class="ruby-identifier">stat</span>(<span class="ruby-string">&#39;src0.txt&#39;</span>).<span class="ruby-identifier">gid</span> <span class="ruby-comment"># =&gt; 1005</span>

<span class="ruby-comment"># User and group as uid and gid.</span>
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">chown</span>(<span class="ruby-value">1004</span>, <span class="ruby-value">1004</span>, <span class="ruby-string">&#39;src0.txt&#39;</span>)
<span class="ruby-constant">File</span>.<span class="ruby-identifier">stat</span>(<span class="ruby-string">&#39;src0.txt&#39;</span>).<span class="ruby-identifier">uid</span> <span class="ruby-comment"># =&gt; 1004</span>
<span class="ruby-constant">File</span>.<span class="ruby-identifier">stat</span>(<span class="ruby-string">&#39;src0.txt&#39;</span>).<span class="ruby-identifier">gid</span> <span class="ruby-comment"># =&gt; 1004</span>

<span class="ruby-comment"># Array of paths.</span>
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">chown</span>(<span class="ruby-value">1006</span>, <span class="ruby-value">1005</span>, [<span class="ruby-string">&#39;src0.txt&#39;</span>, <span class="ruby-string">&#39;src0.dat&#39;</span>])

<span class="ruby-comment"># Directory (not recursive).</span>
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">chown</span>(<span class="ruby-string">&#39;user2&#39;</span>, <span class="ruby-string">&#39;group1&#39;</span>, <span class="ruby-string">&#39;.&#39;</span>)
</pre>

<p>Keyword arguments:</p>
<ul><li>
<p><code>noop: true</code> - does not change permissions; returns <code>nil</code>.</p>
</li><li>
<p><code>verbose: true</code> - prints an equivalent command:</p>

<pre class="ruby"><span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">chown</span>(<span class="ruby-string">&#39;user2&#39;</span>, <span class="ruby-string">&#39;group1&#39;</span>, <span class="ruby-string">&#39;src0.txt&#39;</span>, <span class="ruby-value">noop:</span> <span class="ruby-keyword">true</span>, <span class="ruby-value">verbose:</span> <span class="ruby-keyword">true</span>)
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">chown</span>(<span class="ruby-value">1004</span>, <span class="ruby-value">1004</span>, <span class="ruby-string">&#39;src0.txt&#39;</span>, <span class="ruby-value">noop:</span> <span class="ruby-keyword">true</span>, <span class="ruby-value">verbose:</span> <span class="ruby-keyword">true</span>)
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">chown</span>(<span class="ruby-value">1006</span>, <span class="ruby-value">1005</span>, [<span class="ruby-string">&#39;src0.txt&#39;</span>, <span class="ruby-string">&#39;src0.dat&#39;</span>], <span class="ruby-value">noop:</span> <span class="ruby-keyword">true</span>, <span class="ruby-value">verbose:</span> <span class="ruby-keyword">true</span>)
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">chown</span>(<span class="ruby-string">&#39;user2&#39;</span>, <span class="ruby-string">&#39;group1&#39;</span>, <span class="ruby-identifier">path</span>, <span class="ruby-value">noop:</span> <span class="ruby-keyword">true</span>, <span class="ruby-value">verbose:</span> <span class="ruby-keyword">true</span>)
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">chown</span>(<span class="ruby-string">&#39;user2&#39;</span>, <span class="ruby-string">&#39;group1&#39;</span>, <span class="ruby-string">&#39;.&#39;</span>, <span class="ruby-value">noop:</span> <span class="ruby-keyword">true</span>, <span class="ruby-value">verbose:</span> <span class="ruby-keyword">true</span>)
</pre>

<p>Output:</p>

<pre>chown user2:group1 src0.txt
chown 1004:1004 src0.txt
chown 1006:1005 src0.txt src0.dat
chown user2:group1 src0.txt
chown user2:group1 .</pre>
</li></ul>

<p>Related: <a href="FileUtils.html#method-c-chown_R"><code>FileUtils.chown_R</code></a>.</p>

                              <div class="method-source-code" id="chown-source">
            <pre><span class="ruby-comment"># File fileutils.rb, line 1896</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">chown</span>(<span class="ruby-identifier">user</span>, <span class="ruby-identifier">group</span>, <span class="ruby-identifier">list</span>, <span class="ruby-value">noop:</span> <span class="ruby-keyword">nil</span>, <span class="ruby-value">verbose:</span> <span class="ruby-keyword">nil</span>)
  <span class="ruby-identifier">list</span> = <span class="ruby-identifier">fu_list</span>(<span class="ruby-identifier">list</span>)
  <span class="ruby-identifier">fu_output_message</span> <span class="ruby-identifier">sprintf</span>(<span class="ruby-string">&#39;chown %s %s&#39;</span>,
                            (<span class="ruby-identifier">group</span> <span class="ruby-operator">?</span> <span class="ruby-node">&quot;#{user}:#{group}&quot;</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">user</span> <span class="ruby-operator">||</span> <span class="ruby-string">&#39;:&#39;</span>),
                            <span class="ruby-identifier">list</span>.<span class="ruby-identifier">join</span>(<span class="ruby-string">&#39; &#39;</span>)) <span class="ruby-keyword">if</span> <span class="ruby-identifier">verbose</span>
  <span class="ruby-keyword">return</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">noop</span>
  <span class="ruby-identifier">uid</span> = <span class="ruby-identifier">fu_get_uid</span>(<span class="ruby-identifier">user</span>)
  <span class="ruby-identifier">gid</span> = <span class="ruby-identifier">fu_get_gid</span>(<span class="ruby-identifier">group</span>)
  <span class="ruby-identifier">list</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">path</span><span class="ruby-operator">|</span>
    <span class="ruby-constant">Entry_</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">path</span>).<span class="ruby-identifier">chown</span> <span class="ruby-identifier">uid</span>, <span class="ruby-identifier">gid</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-chown_R" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">chown_R</span><span
                                class="method-args">(user, group, list, noop: nil, verbose: nil, force: nil)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Like <a href="FileUtils.html#method-c-chown"><code>FileUtils.chown</code></a>, but changes owner and group recursively.</p>

                              <div class="method-source-code" id="chown_R-source">
            <pre><span class="ruby-comment"># File fileutils.rb, line 1912</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">chown_R</span>(<span class="ruby-identifier">user</span>, <span class="ruby-identifier">group</span>, <span class="ruby-identifier">list</span>, <span class="ruby-value">noop:</span> <span class="ruby-keyword">nil</span>, <span class="ruby-value">verbose:</span> <span class="ruby-keyword">nil</span>, <span class="ruby-value">force:</span> <span class="ruby-keyword">nil</span>)
  <span class="ruby-identifier">list</span> = <span class="ruby-identifier">fu_list</span>(<span class="ruby-identifier">list</span>)
  <span class="ruby-identifier">fu_output_message</span> <span class="ruby-identifier">sprintf</span>(<span class="ruby-string">&#39;chown -R%s %s %s&#39;</span>,
                            (<span class="ruby-identifier">force</span> <span class="ruby-operator">?</span> <span class="ruby-string">&#39;f&#39;</span> <span class="ruby-operator">:</span> <span class="ruby-string">&#39;&#39;</span>),
                            (<span class="ruby-identifier">group</span> <span class="ruby-operator">?</span> <span class="ruby-node">&quot;#{user}:#{group}&quot;</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">user</span> <span class="ruby-operator">||</span> <span class="ruby-string">&#39;:&#39;</span>),
                            <span class="ruby-identifier">list</span>.<span class="ruby-identifier">join</span>(<span class="ruby-string">&#39; &#39;</span>)) <span class="ruby-keyword">if</span> <span class="ruby-identifier">verbose</span>
  <span class="ruby-keyword">return</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">noop</span>
  <span class="ruby-identifier">uid</span> = <span class="ruby-identifier">fu_get_uid</span>(<span class="ruby-identifier">user</span>)
  <span class="ruby-identifier">gid</span> = <span class="ruby-identifier">fu_get_gid</span>(<span class="ruby-identifier">group</span>)
  <span class="ruby-identifier">list</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">root</span><span class="ruby-operator">|</span>
    <span class="ruby-constant">Entry_</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">root</span>).<span class="ruby-identifier">traverse</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">ent</span><span class="ruby-operator">|</span>
      <span class="ruby-keyword">begin</span>
        <span class="ruby-identifier">ent</span>.<span class="ruby-identifier">chown</span> <span class="ruby-identifier">uid</span>, <span class="ruby-identifier">gid</span>
      <span class="ruby-keyword">rescue</span>
        <span class="ruby-identifier">raise</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">force</span>
      <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-cmp" class="method-detail method-alias">
                            <div class="method-heading">
                              <span class="method-name">cmp</span><span
                                class="method-args">(a, b)</span>
                            </div>

                            <div class="method-description">
                              

                            </div>


                            <div class="aliases">
                              Alias for: <a href="FileUtils.html#method-i-compare_file">compare_file</a>
                            </div>
                          </div>

                  <div id="method-i-compare_file" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">compare_file</span><span
                                class="method-args">(a, b)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns <code>true</code> if the contents of files <code>a</code> and <code>b</code> are identical, <code>false</code> otherwise.</p>

<p>Arguments <code>a</code> and <code>b</code> should be <a href="FileUtils.html#module-FileUtils-label-Path+Arguments">interpretable as a path</a>.</p>

<p><a href="FileUtils.html#method-c-identical-3F"><code>FileUtils.identical?</code></a> and <a href="FileUtils.html#method-c-cmp"><code>FileUtils.cmp</code></a> are aliases for <a href="FileUtils.html#method-c-compare_file"><code>FileUtils.compare_file</code></a>.</p>

<p>Related: <a href="FileUtils.html#method-c-compare_stream"><code>FileUtils.compare_stream</code></a>.</p>

                              <div class="method-source-code" id="compare_file-source">
            <pre><span class="ruby-comment"># File fileutils.rb, line 1507</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">compare_file</span>(<span class="ruby-identifier">a</span>, <span class="ruby-identifier">b</span>)
  <span class="ruby-keyword">return</span> <span class="ruby-keyword">false</span> <span class="ruby-keyword">unless</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">size</span>(<span class="ruby-identifier">a</span>) <span class="ruby-operator">==</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">size</span>(<span class="ruby-identifier">b</span>)
  <span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-identifier">a</span>, <span class="ruby-string">&#39;rb&#39;</span>) {<span class="ruby-operator">|</span><span class="ruby-identifier">fa</span><span class="ruby-operator">|</span>
    <span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-identifier">b</span>, <span class="ruby-string">&#39;rb&#39;</span>) {<span class="ruby-operator">|</span><span class="ruby-identifier">fb</span><span class="ruby-operator">|</span>
      <span class="ruby-keyword">return</span> <span class="ruby-identifier">compare_stream</span>(<span class="ruby-identifier">fa</span>, <span class="ruby-identifier">fb</span>)
    }
  }
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>

                            <div class="aliases">
                              Also aliased as: <a href="FileUtils.html#method-i-identical-3F">identical?</a>, <a href="FileUtils.html#method-i-cmp">cmp</a>
                            </div>

                          </div>

                  <div id="method-i-compare_stream" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">compare_stream</span><span
                                class="method-args">(a, b)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns <code>true</code> if the contents of streams <code>a</code> and <code>b</code> are identical, <code>false</code> otherwise.</p>

<p>Arguments <code>a</code> and <code>b</code> should be <a href="FileUtils.html#module-FileUtils-label-Path+Arguments">interpretable as a path</a>.</p>

<p>Related: <a href="FileUtils.html#method-c-compare_file"><code>FileUtils.compare_file</code></a>.</p>

                              <div class="method-source-code" id="compare_stream-source">
            <pre><span class="ruby-comment"># File fileutils.rb, line 1530</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">compare_stream</span>(<span class="ruby-identifier">a</span>, <span class="ruby-identifier">b</span>)
  <span class="ruby-identifier">bsize</span> = <span class="ruby-identifier">fu_stream_blksize</span>(<span class="ruby-identifier">a</span>, <span class="ruby-identifier">b</span>)

  <span class="ruby-identifier">sa</span> = <span class="ruby-constant">String</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">capacity:</span> <span class="ruby-identifier">bsize</span>)
  <span class="ruby-identifier">sb</span> = <span class="ruby-constant">String</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">capacity:</span> <span class="ruby-identifier">bsize</span>)

  <span class="ruby-keyword">begin</span>
    <span class="ruby-identifier">a</span>.<span class="ruby-identifier">read</span>(<span class="ruby-identifier">bsize</span>, <span class="ruby-identifier">sa</span>)
    <span class="ruby-identifier">b</span>.<span class="ruby-identifier">read</span>(<span class="ruby-identifier">bsize</span>, <span class="ruby-identifier">sb</span>)
    <span class="ruby-keyword">return</span> <span class="ruby-keyword">true</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">sa</span>.<span class="ruby-identifier">empty?</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">sb</span>.<span class="ruby-identifier">empty?</span>
  <span class="ruby-keyword">end</span> <span class="ruby-keyword">while</span> <span class="ruby-identifier">sa</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">sb</span>
  <span class="ruby-keyword">false</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-copy" class="method-detail method-alias">
                            <div class="method-heading">
                              <span class="method-name">copy</span><span
                                class="method-args">(src, dest, preserve: nil, noop: nil, verbose: nil)</span>
                            </div>

                            <div class="method-description">
                              

                            </div>


                            <div class="aliases">
                              Alias for: <a href="FileUtils.html#method-i-cp">cp</a>
                            </div>
                          </div>

                  <div id="method-i-copy_entry" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">copy_entry</span><span
                                class="method-args">(src, dest, preserve = false, dereference_root = false, remove_destination = false)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Recursively copies files from <code>src</code> to <code>dest</code>.</p>

<p>Arguments <code>src</code> and <code>dest</code> should be <a href="FileUtils.html#module-FileUtils-label-Path+Arguments">interpretable as paths</a>.</p>

<p>If <code>src</code> is the path to a file, copies <code>src</code> to <code>dest</code>:</p>

<pre class="ruby"><span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">touch</span>(<span class="ruby-string">&#39;src0.txt&#39;</span>)
<span class="ruby-constant">File</span>.<span class="ruby-identifier">exist?</span>(<span class="ruby-string">&#39;dest0.txt&#39;</span>) <span class="ruby-comment"># =&gt; false</span>
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">copy_entry</span>(<span class="ruby-string">&#39;src0.txt&#39;</span>, <span class="ruby-string">&#39;dest0.txt&#39;</span>)
<span class="ruby-constant">File</span>.<span class="ruby-identifier">file?</span>(<span class="ruby-string">&#39;dest0.txt&#39;</span>)  <span class="ruby-comment"># =&gt; true</span>
</pre>

<p>If <code>src</code> is a directory, recursively copies <code>src</code> to <code>dest</code>:</p>

<pre class="ruby"><span class="ruby-identifier">tree</span>(<span class="ruby-string">&#39;src1&#39;</span>)
<span class="ruby-comment"># =&gt; src1</span>
<span class="ruby-comment">#    |-- dir0</span>
<span class="ruby-comment">#    |   |-- src0.txt</span>
<span class="ruby-comment">#    |   `-- src1.txt</span>
<span class="ruby-comment">#    `-- dir1</span>
<span class="ruby-comment">#        |-- src2.txt</span>
<span class="ruby-comment">#        `-- src3.txt</span>
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">copy_entry</span>(<span class="ruby-string">&#39;src1&#39;</span>, <span class="ruby-string">&#39;dest1&#39;</span>)
<span class="ruby-identifier">tree</span>(<span class="ruby-string">&#39;dest1&#39;</span>)
<span class="ruby-comment"># =&gt; dest1</span>
<span class="ruby-comment">#    |-- dir0</span>
<span class="ruby-comment">#    |   |-- src0.txt</span>
<span class="ruby-comment">#    |   `-- src1.txt</span>
<span class="ruby-comment">#    `-- dir1</span>
<span class="ruby-comment">#        |-- src2.txt</span>
<span class="ruby-comment">#        `-- src3.txt</span>
</pre>

<p>The recursive copying preserves file types for regular files, directories, and symbolic links; other file types (FIFO streams, device files, etc.) are not supported.</p>

<p>Keyword arguments:</p>
<ul><li>
<p><code>dereference_root: true</code> - if <code>src</code> is a symbolic link, follows the link.</p>
</li><li>
<p><code>preserve: true</code> - preserves file times.</p>
</li><li>
<p><code>remove_destination: true</code> - removes <code>dest</code> before copying files.</p>
</li></ul>

<p>Related: <a href="FileUtils.html#module-FileUtils-label-Copying">methods for copying</a>.</p>

                              <div class="method-source-code" id="copy_entry-source">
            <pre><span class="ruby-comment"># File fileutils.rb, line 1040</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">copy_entry</span>(<span class="ruby-identifier">src</span>, <span class="ruby-identifier">dest</span>, <span class="ruby-identifier">preserve</span> = <span class="ruby-keyword">false</span>, <span class="ruby-identifier">dereference_root</span> = <span class="ruby-keyword">false</span>, <span class="ruby-identifier">remove_destination</span> = <span class="ruby-keyword">false</span>)
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">dereference_root</span>
    <span class="ruby-identifier">src</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">realpath</span>(<span class="ruby-identifier">src</span>)
  <span class="ruby-keyword">end</span>

  <span class="ruby-constant">Entry_</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">src</span>, <span class="ruby-keyword">nil</span>, <span class="ruby-keyword">false</span>).<span class="ruby-identifier">wrap_traverse</span>(<span class="ruby-identifier">proc</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">ent</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">destent</span> = <span class="ruby-constant">Entry_</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">dest</span>, <span class="ruby-identifier">ent</span>.<span class="ruby-identifier">rel</span>, <span class="ruby-keyword">false</span>)
    <span class="ruby-constant">File</span>.<span class="ruby-identifier">unlink</span> <span class="ruby-identifier">destent</span>.<span class="ruby-identifier">path</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">remove_destination</span> <span class="ruby-operator">&amp;&amp;</span> (<span class="ruby-constant">File</span>.<span class="ruby-identifier">file?</span>(<span class="ruby-identifier">destent</span>.<span class="ruby-identifier">path</span>) <span class="ruby-operator">||</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">symlink?</span>(<span class="ruby-identifier">destent</span>.<span class="ruby-identifier">path</span>))
    <span class="ruby-identifier">ent</span>.<span class="ruby-identifier">copy</span> <span class="ruby-identifier">destent</span>.<span class="ruby-identifier">path</span>
  <span class="ruby-keyword">end</span>, <span class="ruby-identifier">proc</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">ent</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">destent</span> = <span class="ruby-constant">Entry_</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">dest</span>, <span class="ruby-identifier">ent</span>.<span class="ruby-identifier">rel</span>, <span class="ruby-keyword">false</span>)
    <span class="ruby-identifier">ent</span>.<span class="ruby-identifier">copy_metadata</span> <span class="ruby-identifier">destent</span>.<span class="ruby-identifier">path</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">preserve</span>
  <span class="ruby-keyword">end</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-copy_file" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">copy_file</span><span
                                class="method-args">(src, dest, preserve = false, dereference = true)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Copies file from <code>src</code> to <code>dest</code>, which should not be directories.</p>

<p>Arguments <code>src</code> and <code>dest</code> should be <a href="FileUtils.html#module-FileUtils-label-Path+Arguments">interpretable as paths</a>.</p>

<p>Examples:</p>

<pre class="ruby"><span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">touch</span>(<span class="ruby-string">&#39;src0.txt&#39;</span>)
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">copy_file</span>(<span class="ruby-string">&#39;src0.txt&#39;</span>, <span class="ruby-string">&#39;dest0.txt&#39;</span>)
<span class="ruby-constant">File</span>.<span class="ruby-identifier">file?</span>(<span class="ruby-string">&#39;dest0.txt&#39;</span>) <span class="ruby-comment"># =&gt; true</span>
</pre>

<p>Keyword arguments:</p>
<ul><li>
<p><code>dereference: false</code> - if <code>src</code> is a symbolic link, does not follow the link.</p>
</li><li>
<p><code>preserve: true</code> - preserves file times.</p>
</li><li>
<p><code>remove_destination: true</code> - removes <code>dest</code> before copying files.</p>
</li></ul>

<p>Related: <a href="FileUtils.html#module-FileUtils-label-Copying">methods for copying</a>.</p>

                              <div class="method-source-code" id="copy_file-source">
            <pre><span class="ruby-comment"># File fileutils.rb, line 1076</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">copy_file</span>(<span class="ruby-identifier">src</span>, <span class="ruby-identifier">dest</span>, <span class="ruby-identifier">preserve</span> = <span class="ruby-keyword">false</span>, <span class="ruby-identifier">dereference</span> = <span class="ruby-keyword">true</span>)
  <span class="ruby-identifier">ent</span> = <span class="ruby-constant">Entry_</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">src</span>, <span class="ruby-keyword">nil</span>, <span class="ruby-identifier">dereference</span>)
  <span class="ruby-identifier">ent</span>.<span class="ruby-identifier">copy_file</span> <span class="ruby-identifier">dest</span>
  <span class="ruby-identifier">ent</span>.<span class="ruby-identifier">copy_metadata</span> <span class="ruby-identifier">dest</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">preserve</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-copy_stream" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">copy_stream</span><span
                                class="method-args">(src, dest)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Copies IO stream <code>src</code> to IO stream <code>dest</code> via IO.copy_stream.</p>

<p>Related: <a href="FileUtils.html#module-FileUtils-label-Copying">methods for copying</a>.</p>

                              <div class="method-source-code" id="copy_stream-source">
            <pre><span class="ruby-comment"># File fileutils.rb, line 1088</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">copy_stream</span>(<span class="ruby-identifier">src</span>, <span class="ruby-identifier">dest</span>)
  <span class="ruby-constant">IO</span>.<span class="ruby-identifier">copy_stream</span>(<span class="ruby-identifier">src</span>, <span class="ruby-identifier">dest</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-cp" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">cp</span><span
                                class="method-args">(src, dest, preserve: nil, noop: nil, verbose: nil)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Copies files.</p>

<p>Arguments <code>src</code> (a single path or an array of paths) and <code>dest</code> (a single path) should be <a href="FileUtils.html#module-FileUtils-label-Path+Arguments">interpretable as paths</a>.</p>

<p>If <code>src</code> is the path to a file and <code>dest</code> is not the path to a directory, copies <code>src</code> to <code>dest</code>:</p>

<pre class="ruby"><span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">touch</span>(<span class="ruby-string">&#39;src0.txt&#39;</span>)
<span class="ruby-constant">File</span>.<span class="ruby-identifier">exist?</span>(<span class="ruby-string">&#39;dest0.txt&#39;</span>) <span class="ruby-comment"># =&gt; false</span>
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">cp</span>(<span class="ruby-string">&#39;src0.txt&#39;</span>, <span class="ruby-string">&#39;dest0.txt&#39;</span>)
<span class="ruby-constant">File</span>.<span class="ruby-identifier">file?</span>(<span class="ruby-string">&#39;dest0.txt&#39;</span>)  <span class="ruby-comment"># =&gt; true</span>
</pre>

<p>If <code>src</code> is the path to a file and <code>dest</code> is the path to a directory, copies <code>src</code> to <code>dest/src</code>:</p>

<pre class="ruby"><span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">touch</span>(<span class="ruby-string">&#39;src1.txt&#39;</span>)
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">mkdir</span>(<span class="ruby-string">&#39;dest1&#39;</span>)
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">cp</span>(<span class="ruby-string">&#39;src1.txt&#39;</span>, <span class="ruby-string">&#39;dest1&#39;</span>)
<span class="ruby-constant">File</span>.<span class="ruby-identifier">file?</span>(<span class="ruby-string">&#39;dest1/src1.txt&#39;</span>) <span class="ruby-comment"># =&gt; true</span>
</pre>

<p>If <code>src</code> is an array of paths to files and <code>dest</code> is the path to a directory, copies from each <code>src</code> to <code>dest</code>:</p>

<pre class="ruby"><span class="ruby-identifier">src_file_paths</span> = [<span class="ruby-string">&#39;src2.txt&#39;</span>, <span class="ruby-string">&#39;src2.dat&#39;</span>]
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">touch</span>(<span class="ruby-identifier">src_file_paths</span>)
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">mkdir</span>(<span class="ruby-string">&#39;dest2&#39;</span>)
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">cp</span>(<span class="ruby-identifier">src_file_paths</span>, <span class="ruby-string">&#39;dest2&#39;</span>)
<span class="ruby-constant">File</span>.<span class="ruby-identifier">file?</span>(<span class="ruby-string">&#39;dest2/src2.txt&#39;</span>) <span class="ruby-comment"># =&gt; true</span>
<span class="ruby-constant">File</span>.<span class="ruby-identifier">file?</span>(<span class="ruby-string">&#39;dest2/src2.dat&#39;</span>) <span class="ruby-comment"># =&gt; true</span>
</pre>

<p>Keyword arguments:</p>
<ul><li>
<p><code>preserve: true</code> - preserves file times.</p>
</li><li>
<p><code>noop: true</code> - does not copy files.</p>
</li><li>
<p><code>verbose: true</code> - prints an equivalent command:</p>

<pre class="ruby"><span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">cp</span>(<span class="ruby-string">&#39;src0.txt&#39;</span>, <span class="ruby-string">&#39;dest0.txt&#39;</span>, <span class="ruby-value">noop:</span> <span class="ruby-keyword">true</span>, <span class="ruby-value">verbose:</span> <span class="ruby-keyword">true</span>)
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">cp</span>(<span class="ruby-string">&#39;src1.txt&#39;</span>, <span class="ruby-string">&#39;dest1&#39;</span>, <span class="ruby-value">noop:</span> <span class="ruby-keyword">true</span>, <span class="ruby-value">verbose:</span> <span class="ruby-keyword">true</span>)
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">cp</span>(<span class="ruby-identifier">src_file_paths</span>, <span class="ruby-string">&#39;dest2&#39;</span>, <span class="ruby-value">noop:</span> <span class="ruby-keyword">true</span>, <span class="ruby-value">verbose:</span> <span class="ruby-keyword">true</span>)
</pre>

<p>Output:</p>

<pre class="ruby"><span class="ruby-identifier">cp</span> <span class="ruby-identifier">src0</span>.<span class="ruby-identifier">txt</span> <span class="ruby-identifier">dest0</span>.<span class="ruby-identifier">txt</span>
<span class="ruby-identifier">cp</span> <span class="ruby-identifier">src1</span>.<span class="ruby-identifier">txt</span> <span class="ruby-identifier">dest1</span>
<span class="ruby-identifier">cp</span> <span class="ruby-identifier">src2</span>.<span class="ruby-identifier">txt</span> <span class="ruby-identifier">src2</span>.<span class="ruby-identifier">dat</span> <span class="ruby-identifier">dest2</span>
</pre>
</li></ul>

<p>Raises an exception if <code>src</code> is a directory.</p>

<p>Related: <a href="FileUtils.html#module-FileUtils-label-Copying">methods for copying</a>.</p>

                              <div class="method-source-code" id="cp-source">
            <pre><span class="ruby-comment"># File fileutils.rb, line 873</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">cp</span>(<span class="ruby-identifier">src</span>, <span class="ruby-identifier">dest</span>, <span class="ruby-value">preserve:</span> <span class="ruby-keyword">nil</span>, <span class="ruby-value">noop:</span> <span class="ruby-keyword">nil</span>, <span class="ruby-value">verbose:</span> <span class="ruby-keyword">nil</span>)
  <span class="ruby-identifier">fu_output_message</span> <span class="ruby-node">&quot;cp#{preserve ? &#39; -p&#39; : &#39;&#39;} #{[src,dest].flatten.join &#39; &#39;}&quot;</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">verbose</span>
  <span class="ruby-keyword">return</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">noop</span>
  <span class="ruby-identifier">fu_each_src_dest</span>(<span class="ruby-identifier">src</span>, <span class="ruby-identifier">dest</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">s</span>, <span class="ruby-identifier">d</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">copy_file</span> <span class="ruby-identifier">s</span>, <span class="ruby-identifier">d</span>, <span class="ruby-identifier">preserve</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>

                            <div class="aliases">
                              Also aliased as: <a href="FileUtils.html#method-i-copy">copy</a>
                            </div>

                          </div>

                  <div id="method-i-cp_lr" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">cp_lr</span><span
                                class="method-args">(src, dest, noop: nil, verbose: nil, dereference_root: true, remove_destination: false)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Creates <a href="https://en.wikipedia.org/wiki/Hard_link">hard links</a>.</p>

<p>Arguments <code>src</code> (a single path or an array of paths) and <code>dest</code> (a single path) should be <a href="FileUtils.html#module-FileUtils-label-Path+Arguments">interpretable as paths</a>.</p>

<p>If <code>src</code> is the path to a directory and <code>dest</code> does not exist, creates links <code>dest</code> and descendents pointing to <code>src</code> and its descendents:</p>

<pre class="ruby"><span class="ruby-identifier">tree</span>(<span class="ruby-string">&#39;src0&#39;</span>)
<span class="ruby-comment"># =&gt; src0</span>
<span class="ruby-comment">#    |-- sub0</span>
<span class="ruby-comment">#    |   |-- src0.txt</span>
<span class="ruby-comment">#    |   `-- src1.txt</span>
<span class="ruby-comment">#    `-- sub1</span>
<span class="ruby-comment">#        |-- src2.txt</span>
<span class="ruby-comment">#        `-- src3.txt</span>
<span class="ruby-constant">File</span>.<span class="ruby-identifier">exist?</span>(<span class="ruby-string">&#39;dest0&#39;</span>) <span class="ruby-comment"># =&gt; false</span>
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">cp_lr</span>(<span class="ruby-string">&#39;src0&#39;</span>, <span class="ruby-string">&#39;dest0&#39;</span>)
<span class="ruby-identifier">tree</span>(<span class="ruby-string">&#39;dest0&#39;</span>)
<span class="ruby-comment"># =&gt; dest0</span>
<span class="ruby-comment">#    |-- sub0</span>
<span class="ruby-comment">#    |   |-- src0.txt</span>
<span class="ruby-comment">#    |   `-- src1.txt</span>
<span class="ruby-comment">#    `-- sub1</span>
<span class="ruby-comment">#        |-- src2.txt</span>
<span class="ruby-comment">#        `-- src3.txt</span>
</pre>

<p>If <code>src</code> and <code>dest</code> are both paths to directories, creates links <code>dest/src</code> and descendents pointing to <code>src</code> and its descendents:</p>

<pre class="ruby"><span class="ruby-identifier">tree</span>(<span class="ruby-string">&#39;src1&#39;</span>)
<span class="ruby-comment"># =&gt; src1</span>
<span class="ruby-comment">#    |-- sub0</span>
<span class="ruby-comment">#    |   |-- src0.txt</span>
<span class="ruby-comment">#    |   `-- src1.txt</span>
<span class="ruby-comment">#    `-- sub1</span>
<span class="ruby-comment">#        |-- src2.txt</span>
<span class="ruby-comment">#        `-- src3.txt</span>
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">mkdir</span>(<span class="ruby-string">&#39;dest1&#39;</span>)
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">cp_lr</span>(<span class="ruby-string">&#39;src1&#39;</span>, <span class="ruby-string">&#39;dest1&#39;</span>)
<span class="ruby-identifier">tree</span>(<span class="ruby-string">&#39;dest1&#39;</span>)
<span class="ruby-comment"># =&gt; dest1</span>
<span class="ruby-comment">#    `-- src1</span>
<span class="ruby-comment">#        |-- sub0</span>
<span class="ruby-comment">#        |   |-- src0.txt</span>
<span class="ruby-comment">#        |   `-- src1.txt</span>
<span class="ruby-comment">#        `-- sub1</span>
<span class="ruby-comment">#            |-- src2.txt</span>
<span class="ruby-comment">#            `-- src3.txt</span>
</pre>

<p>If <code>src</code> is an array of paths to entries and <code>dest</code> is the path to a directory, for each path <code>filepath</code> in <code>src</code>, creates a link at <code>dest/filepath</code> pointing to that path:</p>

<pre class="ruby"><span class="ruby-identifier">tree</span>(<span class="ruby-string">&#39;src2&#39;</span>)
<span class="ruby-comment"># =&gt; src2</span>
<span class="ruby-comment">#    |-- sub0</span>
<span class="ruby-comment">#    |   |-- src0.txt</span>
<span class="ruby-comment">#    |   `-- src1.txt</span>
<span class="ruby-comment">#    `-- sub1</span>
<span class="ruby-comment">#        |-- src2.txt</span>
<span class="ruby-comment">#        `-- src3.txt</span>
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">mkdir</span>(<span class="ruby-string">&#39;dest2&#39;</span>)
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">cp_lr</span>([<span class="ruby-string">&#39;src2/sub0&#39;</span>, <span class="ruby-string">&#39;src2/sub1&#39;</span>], <span class="ruby-string">&#39;dest2&#39;</span>)
<span class="ruby-identifier">tree</span>(<span class="ruby-string">&#39;dest2&#39;</span>)
<span class="ruby-comment"># =&gt; dest2</span>
<span class="ruby-comment">#    |-- sub0</span>
<span class="ruby-comment">#    |   |-- src0.txt</span>
<span class="ruby-comment">#    |   `-- src1.txt</span>
<span class="ruby-comment">#    `-- sub1</span>
<span class="ruby-comment">#        |-- src2.txt</span>
<span class="ruby-comment">#        `-- src3.txt</span>
</pre>

<p>Keyword arguments:</p>
<ul><li>
<p><code>dereference_root: false</code> - if <code>src</code> is a symbolic link, does not dereference it.</p>
</li><li>
<p><code>noop: true</code> - does not create links.</p>
</li><li>
<p><code>remove_destination: true</code> - removes <code>dest</code> before creating links.</p>
</li><li>
<p><code>verbose: true</code> - prints an equivalent command:</p>

<pre class="ruby"><span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">cp_lr</span>(<span class="ruby-string">&#39;src0&#39;</span>, <span class="ruby-string">&#39;dest0&#39;</span>, <span class="ruby-value">noop:</span> <span class="ruby-keyword">true</span>, <span class="ruby-value">verbose:</span> <span class="ruby-keyword">true</span>)
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">cp_lr</span>(<span class="ruby-string">&#39;src1&#39;</span>, <span class="ruby-string">&#39;dest1&#39;</span>, <span class="ruby-value">noop:</span> <span class="ruby-keyword">true</span>, <span class="ruby-value">verbose:</span> <span class="ruby-keyword">true</span>)
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">cp_lr</span>([<span class="ruby-string">&#39;src2/sub0&#39;</span>, <span class="ruby-string">&#39;src2/sub1&#39;</span>], <span class="ruby-string">&#39;dest2&#39;</span>, <span class="ruby-value">noop:</span> <span class="ruby-keyword">true</span>, <span class="ruby-value">verbose:</span> <span class="ruby-keyword">true</span>)
</pre>

<p>Output:</p>

<pre>cp -lr src0 dest0
cp -lr src1 dest1
cp -lr src2/sub0 src2/sub1 dest2</pre>
</li></ul>

<p>Raises an exception if <code>dest</code> is the path to an existing file or directory and keyword argument <code>remove_destination: true</code> is not given.</p>

<p>Related: <a href="FileUtils.html#module-FileUtils-label-Copying">methods for copying</a>.</p>

                              <div class="method-source-code" id="cp_lr-source">
            <pre><span class="ruby-comment"># File fileutils.rb, line 627</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">cp_lr</span>(<span class="ruby-identifier">src</span>, <span class="ruby-identifier">dest</span>, <span class="ruby-value">noop:</span> <span class="ruby-keyword">nil</span>, <span class="ruby-value">verbose:</span> <span class="ruby-keyword">nil</span>,
          <span class="ruby-value">dereference_root:</span> <span class="ruby-keyword">true</span>, <span class="ruby-value">remove_destination:</span> <span class="ruby-keyword">false</span>)
  <span class="ruby-identifier">fu_output_message</span> <span class="ruby-node">&quot;cp -lr#{remove_destination ? &#39; --remove-destination&#39; : &#39;&#39;} #{[src,dest].flatten.join &#39; &#39;}&quot;</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">verbose</span>
  <span class="ruby-keyword">return</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">noop</span>
  <span class="ruby-identifier">fu_each_src_dest</span>(<span class="ruby-identifier">src</span>, <span class="ruby-identifier">dest</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">s</span>, <span class="ruby-identifier">d</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">link_entry</span> <span class="ruby-identifier">s</span>, <span class="ruby-identifier">d</span>, <span class="ruby-identifier">dereference_root</span>, <span class="ruby-identifier">remove_destination</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-cp_r" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">cp_r</span><span
                                class="method-args">(src, dest, preserve: nil, noop: nil, verbose: nil, dereference_root: true, remove_destination: nil)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Recursively copies files.</p>

<p>Arguments <code>src</code> (a single path or an array of paths) and <code>dest</code> (a single path) should be <a href="FileUtils.html#module-FileUtils-label-Path+Arguments">interpretable as paths</a>.</p>

<p>The mode, owner, and group are retained in the copy; to change those, use <a href="FileUtils.html#method-c-install"><code>FileUtils.install</code></a> instead.</p>

<p>If <code>src</code> is the path to a file and <code>dest</code> is not the path to a directory, copies <code>src</code> to <code>dest</code>:</p>

<pre class="ruby"><span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">touch</span>(<span class="ruby-string">&#39;src0.txt&#39;</span>)
<span class="ruby-constant">File</span>.<span class="ruby-identifier">exist?</span>(<span class="ruby-string">&#39;dest0.txt&#39;</span>) <span class="ruby-comment"># =&gt; false</span>
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">cp_r</span>(<span class="ruby-string">&#39;src0.txt&#39;</span>, <span class="ruby-string">&#39;dest0.txt&#39;</span>)
<span class="ruby-constant">File</span>.<span class="ruby-identifier">file?</span>(<span class="ruby-string">&#39;dest0.txt&#39;</span>)  <span class="ruby-comment"># =&gt; true</span>
</pre>

<p>If <code>src</code> is the path to a file and <code>dest</code> is the path to a directory, copies <code>src</code> to <code>dest/src</code>:</p>

<pre class="ruby"><span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">touch</span>(<span class="ruby-string">&#39;src1.txt&#39;</span>)
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">mkdir</span>(<span class="ruby-string">&#39;dest1&#39;</span>)
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">cp_r</span>(<span class="ruby-string">&#39;src1.txt&#39;</span>, <span class="ruby-string">&#39;dest1&#39;</span>)
<span class="ruby-constant">File</span>.<span class="ruby-identifier">file?</span>(<span class="ruby-string">&#39;dest1/src1.txt&#39;</span>) <span class="ruby-comment"># =&gt; true</span>
</pre>

<p>If <code>src</code> is the path to a directory and <code>dest</code> does not exist, recursively copies <code>src</code> to <code>dest</code>:</p>

<pre class="ruby"><span class="ruby-identifier">tree</span>(<span class="ruby-string">&#39;src2&#39;</span>)
<span class="ruby-comment"># =&gt; src2</span>
<span class="ruby-comment">#    |-- dir0</span>
<span class="ruby-comment">#    |   |-- src0.txt</span>
<span class="ruby-comment">#    |   `-- src1.txt</span>
<span class="ruby-comment">#    `-- dir1</span>
<span class="ruby-comment">#    |-- src2.txt</span>
<span class="ruby-comment">#    `-- src3.txt</span>
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">exist?</span>(<span class="ruby-string">&#39;dest2&#39;</span>) <span class="ruby-comment"># =&gt; false</span>
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">cp_r</span>(<span class="ruby-string">&#39;src2&#39;</span>, <span class="ruby-string">&#39;dest2&#39;</span>)
<span class="ruby-identifier">tree</span>(<span class="ruby-string">&#39;dest2&#39;</span>)
<span class="ruby-comment"># =&gt; dest2</span>
<span class="ruby-comment">#    |-- dir0</span>
<span class="ruby-comment">#    |   |-- src0.txt</span>
<span class="ruby-comment">#    |   `-- src1.txt</span>
<span class="ruby-comment">#    `-- dir1</span>
<span class="ruby-comment">#    |-- src2.txt</span>
<span class="ruby-comment">#    `-- src3.txt</span>
</pre>

<p>If <code>src</code> and <code>dest</code> are paths to directories, recursively copies <code>src</code> to <code>dest/src</code>:</p>

<pre class="ruby"><span class="ruby-identifier">tree</span>(<span class="ruby-string">&#39;src3&#39;</span>)
<span class="ruby-comment"># =&gt; src3</span>
<span class="ruby-comment">#    |-- dir0</span>
<span class="ruby-comment">#    |   |-- src0.txt</span>
<span class="ruby-comment">#    |   `-- src1.txt</span>
<span class="ruby-comment">#    `-- dir1</span>
<span class="ruby-comment">#    |-- src2.txt</span>
<span class="ruby-comment">#    `-- src3.txt</span>
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">mkdir</span>(<span class="ruby-string">&#39;dest3&#39;</span>)
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">cp_r</span>(<span class="ruby-string">&#39;src3&#39;</span>, <span class="ruby-string">&#39;dest3&#39;</span>)
<span class="ruby-identifier">tree</span>(<span class="ruby-string">&#39;dest3&#39;</span>)
<span class="ruby-comment"># =&gt; dest3</span>
<span class="ruby-comment">#    `-- src3</span>
<span class="ruby-comment">#      |-- dir0</span>
<span class="ruby-comment">#      |   |-- src0.txt</span>
<span class="ruby-comment">#      |   `-- src1.txt</span>
<span class="ruby-comment">#      `-- dir1</span>
<span class="ruby-comment">#          |-- src2.txt</span>
<span class="ruby-comment">#          `-- src3.txt</span>
</pre>

<p>If <code>src</code> is an array of paths and <code>dest</code> is a directory, recursively copies from each path in <code>src</code> to <code>dest</code>; the paths in <code>src</code> may point to files and/or directories.</p>

<p>Keyword arguments:</p>
<ul><li>
<p><code>dereference_root: false</code> - if <code>src</code> is a symbolic link, does not dereference it.</p>
</li><li>
<p><code>noop: true</code> - does not copy files.</p>
</li><li>
<p><code>preserve: true</code> - preserves file times.</p>
</li><li>
<p><code>remove_destination: true</code> - removes <code>dest</code> before copying files.</p>
</li><li>
<p><code>verbose: true</code> - prints an equivalent command:</p>

<pre class="ruby"><span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">cp_r</span>(<span class="ruby-string">&#39;src0.txt&#39;</span>, <span class="ruby-string">&#39;dest0.txt&#39;</span>, <span class="ruby-value">noop:</span> <span class="ruby-keyword">true</span>, <span class="ruby-value">verbose:</span> <span class="ruby-keyword">true</span>)
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">cp_r</span>(<span class="ruby-string">&#39;src1.txt&#39;</span>, <span class="ruby-string">&#39;dest1&#39;</span>, <span class="ruby-value">noop:</span> <span class="ruby-keyword">true</span>, <span class="ruby-value">verbose:</span> <span class="ruby-keyword">true</span>)
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">cp_r</span>(<span class="ruby-string">&#39;src2&#39;</span>, <span class="ruby-string">&#39;dest2&#39;</span>, <span class="ruby-value">noop:</span> <span class="ruby-keyword">true</span>, <span class="ruby-value">verbose:</span> <span class="ruby-keyword">true</span>)
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">cp_r</span>(<span class="ruby-string">&#39;src3&#39;</span>, <span class="ruby-string">&#39;dest3&#39;</span>, <span class="ruby-value">noop:</span> <span class="ruby-keyword">true</span>, <span class="ruby-value">verbose:</span> <span class="ruby-keyword">true</span>)
</pre>

<p>Output:</p>

<pre>cp -r src0.txt dest0.txt
cp -r src1.txt dest1
cp -r src2 dest2
cp -r src3 dest3</pre>
</li></ul>

<p>Raises an exception of <code>src</code> is the path to a directory and <code>dest</code> is the path to a file.</p>

<p>Related: <a href="FileUtils.html#module-FileUtils-label-Copying">methods for copying</a>.</p>

                              <div class="method-source-code" id="cp_r-source">
            <pre><span class="ruby-comment"># File fileutils.rb, line 985</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">cp_r</span>(<span class="ruby-identifier">src</span>, <span class="ruby-identifier">dest</span>, <span class="ruby-value">preserve:</span> <span class="ruby-keyword">nil</span>, <span class="ruby-value">noop:</span> <span class="ruby-keyword">nil</span>, <span class="ruby-value">verbose:</span> <span class="ruby-keyword">nil</span>,
         <span class="ruby-value">dereference_root:</span> <span class="ruby-keyword">true</span>, <span class="ruby-value">remove_destination:</span> <span class="ruby-keyword">nil</span>)
  <span class="ruby-identifier">fu_output_message</span> <span class="ruby-node">&quot;cp -r#{preserve ? &#39;p&#39; : &#39;&#39;}#{remove_destination ? &#39; --remove-destination&#39; : &#39;&#39;} #{[src,dest].flatten.join &#39; &#39;}&quot;</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">verbose</span>
  <span class="ruby-keyword">return</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">noop</span>
  <span class="ruby-identifier">fu_each_src_dest</span>(<span class="ruby-identifier">src</span>, <span class="ruby-identifier">dest</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">s</span>, <span class="ruby-identifier">d</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">copy_entry</span> <span class="ruby-identifier">s</span>, <span class="ruby-identifier">d</span>, <span class="ruby-identifier">preserve</span>, <span class="ruby-identifier">dereference_root</span>, <span class="ruby-identifier">remove_destination</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-fu_clean_components" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">fu_clean_components</span><span
                                class="method-args">(*comp)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="fu_clean_components-source">
            <pre><span class="ruby-comment"># File fileutils.rb, line 2527</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">fu_clean_components</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">comp</span>)
  <span class="ruby-identifier">comp</span>.<span class="ruby-identifier">shift</span> <span class="ruby-keyword">while</span> <span class="ruby-identifier">comp</span>.<span class="ruby-identifier">first</span> <span class="ruby-operator">==</span> <span class="ruby-string">&quot;.&quot;</span>
  <span class="ruby-keyword">return</span> <span class="ruby-identifier">comp</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">comp</span>.<span class="ruby-identifier">empty?</span>
  <span class="ruby-identifier">clean</span> = [<span class="ruby-identifier">comp</span>.<span class="ruby-identifier">shift</span>]
  <span class="ruby-identifier">path</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">clean</span>, <span class="ruby-string">&quot;&quot;</span>) <span class="ruby-comment"># ending with File::SEPARATOR</span>
  <span class="ruby-keyword">while</span> <span class="ruby-identifier">c</span> = <span class="ruby-identifier">comp</span>.<span class="ruby-identifier">shift</span>
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">c</span> <span class="ruby-operator">==</span> <span class="ruby-string">&quot;..&quot;</span> <span class="ruby-keyword">and</span> <span class="ruby-identifier">clean</span>.<span class="ruby-identifier">last</span> <span class="ruby-operator">!=</span> <span class="ruby-string">&quot;..&quot;</span> <span class="ruby-keyword">and</span> <span class="ruby-operator">!</span>(<span class="ruby-identifier">fu_have_symlink?</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">symlink?</span>(<span class="ruby-identifier">path</span>))
      <span class="ruby-identifier">clean</span>.<span class="ruby-identifier">pop</span>
      <span class="ruby-identifier">path</span>.<span class="ruby-identifier">chomp!</span>(<span class="ruby-regexp">%r((?&lt;=\A|/)[^/]+/\z)</span>, <span class="ruby-string">&quot;&quot;</span>)
    <span class="ruby-keyword">else</span>
      <span class="ruby-identifier">clean</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">c</span>
      <span class="ruby-identifier">path</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">c</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-string">&quot;/&quot;</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-identifier">clean</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-fu_split_path" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">fu_split_path</span><span
                                class="method-args">(path)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="fu_split_path-source">
            <pre><span class="ruby-comment"># File fileutils.rb, line 2506</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">fu_split_path</span>(<span class="ruby-identifier">path</span>)
  <span class="ruby-identifier">path</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">path</span>(<span class="ruby-identifier">path</span>)
  <span class="ruby-identifier">list</span> = []
  <span class="ruby-keyword">until</span> (<span class="ruby-identifier">parent</span>, <span class="ruby-identifier">base</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">split</span>(<span class="ruby-identifier">path</span>); <span class="ruby-identifier">parent</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">path</span> <span class="ruby-keyword">or</span> <span class="ruby-identifier">parent</span> <span class="ruby-operator">==</span> <span class="ruby-string">&quot;.&quot;</span>)
    <span class="ruby-identifier">list</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">base</span>
    <span class="ruby-identifier">path</span> = <span class="ruby-identifier">parent</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-identifier">list</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">path</span>
  <span class="ruby-identifier">list</span>.<span class="ruby-identifier">reverse!</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-fu_starting_path-3F" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">fu_starting_path?</span><span
                                class="method-args">(path)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="fu_starting_path-3F-source">
            <pre><span class="ruby-comment"># File fileutils.rb, line 2546</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">fu_starting_path?</span>(<span class="ruby-identifier">path</span>)
  <span class="ruby-identifier">path</span>&amp;.<span class="ruby-identifier">start_with?</span>(<span class="ruby-regexp">%r(\w:|/)</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-getwd" class="method-detail method-alias">
                            <div class="method-heading">
                              <span class="method-name">getwd</span><span
                                class="method-args">()</span>
                            </div>

                            <div class="method-description">
                              

                            </div>


                            <div class="aliases">
                              Alias for: <a href="FileUtils.html#method-i-pwd">pwd</a>
                            </div>
                          </div>

                  <div id="method-i-identical-3F" class="method-detail method-alias">
                            <div class="method-heading">
                              <span class="method-name">identical?</span><span
                                class="method-args">(a, b)</span>
                            </div>

                            <div class="method-description">
                              

                            </div>


                            <div class="aliases">
                              Alias for: <a href="FileUtils.html#method-i-compare_file">compare_file</a>
                            </div>
                          </div>

                  <div id="method-i-install" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">install</span><span
                                class="method-args">(src, dest, mode: nil, owner: nil, group: nil, preserve: nil, noop: nil, verbose: nil)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Copies a file entry. See <a href="https://man7.org/linux/man-pages/man1/install.1.html">install(1)</a>.</p>

<p>Arguments <code>src</code> (a single path or an array of paths) and <code>dest</code> (a single path) should be <a href="FileUtils.html#module-FileUtils-label-Path+Arguments">interpretable as paths</a>;</p>

<p>If the entry at <code>dest</code> does not exist, copies from <code>src</code> to <code>dest</code>:</p>

<pre class="ruby"><span class="ruby-constant">File</span>.<span class="ruby-identifier">read</span>(<span class="ruby-string">&#39;src0.txt&#39;</span>)    <span class="ruby-comment"># =&gt; &quot;aaa\n&quot;</span>
<span class="ruby-constant">File</span>.<span class="ruby-identifier">exist?</span>(<span class="ruby-string">&#39;dest0.txt&#39;</span>) <span class="ruby-comment"># =&gt; false</span>
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">install</span>(<span class="ruby-string">&#39;src0.txt&#39;</span>, <span class="ruby-string">&#39;dest0.txt&#39;</span>)
<span class="ruby-constant">File</span>.<span class="ruby-identifier">read</span>(<span class="ruby-string">&#39;dest0.txt&#39;</span>)   <span class="ruby-comment"># =&gt; &quot;aaa\n&quot;</span>
</pre>

<p>If <code>dest</code> is a file entry, copies from <code>src</code> to <code>dest</code>, overwriting:</p>

<pre class="ruby"><span class="ruby-constant">File</span>.<span class="ruby-identifier">read</span>(<span class="ruby-string">&#39;src1.txt&#39;</span>)  <span class="ruby-comment"># =&gt; &quot;aaa\n&quot;</span>
<span class="ruby-constant">File</span>.<span class="ruby-identifier">read</span>(<span class="ruby-string">&#39;dest1.txt&#39;</span>) <span class="ruby-comment"># =&gt; &quot;bbb\n&quot;</span>
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">install</span>(<span class="ruby-string">&#39;src1.txt&#39;</span>, <span class="ruby-string">&#39;dest1.txt&#39;</span>)
<span class="ruby-constant">File</span>.<span class="ruby-identifier">read</span>(<span class="ruby-string">&#39;dest1.txt&#39;</span>) <span class="ruby-comment"># =&gt; &quot;aaa\n&quot;</span>
</pre>

<p>If <code>dest</code> is a directory entry, copies from <code>src</code> to <code>dest/src</code>, overwriting if necessary:</p>

<pre class="ruby"><span class="ruby-constant">File</span>.<span class="ruby-identifier">read</span>(<span class="ruby-string">&#39;src2.txt&#39;</span>)       <span class="ruby-comment"># =&gt; &quot;aaa\n&quot;</span>
<span class="ruby-constant">File</span>.<span class="ruby-identifier">read</span>(<span class="ruby-string">&#39;dest2/src2.txt&#39;</span>) <span class="ruby-comment"># =&gt; &quot;bbb\n&quot;</span>
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">install</span>(<span class="ruby-string">&#39;src2.txt&#39;</span>, <span class="ruby-string">&#39;dest2&#39;</span>)
<span class="ruby-constant">File</span>.<span class="ruby-identifier">read</span>(<span class="ruby-string">&#39;dest2/src2.txt&#39;</span>) <span class="ruby-comment"># =&gt; &quot;aaa\n&quot;</span>
</pre>

<p>If <code>src</code> is an array of paths and <code>dest</code> points to a directory, copies each path <code>path</code> in <code>src</code> to <code>dest/path</code>:</p>

<pre class="ruby"><span class="ruby-constant">File</span>.<span class="ruby-identifier">file?</span>(<span class="ruby-string">&#39;src3.txt&#39;</span>) <span class="ruby-comment"># =&gt; true</span>
<span class="ruby-constant">File</span>.<span class="ruby-identifier">file?</span>(<span class="ruby-string">&#39;src3.dat&#39;</span>) <span class="ruby-comment"># =&gt; true</span>
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">mkdir</span>(<span class="ruby-string">&#39;dest3&#39;</span>)
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">install</span>([<span class="ruby-string">&#39;src3.txt&#39;</span>, <span class="ruby-string">&#39;src3.dat&#39;</span>], <span class="ruby-string">&#39;dest3&#39;</span>)
<span class="ruby-constant">File</span>.<span class="ruby-identifier">file?</span>(<span class="ruby-string">&#39;dest3/src3.txt&#39;</span>) <span class="ruby-comment"># =&gt; true</span>
<span class="ruby-constant">File</span>.<span class="ruby-identifier">file?</span>(<span class="ruby-string">&#39;dest3/src3.dat&#39;</span>) <span class="ruby-comment"># =&gt; true</span>
</pre>

<p>Keyword arguments:</p>
<ul><li>
<p><code>group: <em>group</em></code> - changes the group if not <code>nil</code>, using File.chown.</p>
</li><li>
<p><code>mode: <em>permissions</em></code> - changes the permissions. using File.chmod.</p>
</li><li>
<p><code>noop: true</code> - does not copy entries; returns <code>nil</code>.</p>
</li><li>
<p><code>owner: <em>owner</em></code> - changes the owner if not <code>nil</code>, using File.chown.</p>
</li><li>
<p><code>preserve: true</code> - preserve timestamps using File.utime.</p>
</li><li>
<p><code>verbose: true</code> - prints an equivalent command:</p>

<pre class="ruby"><span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">install</span>(<span class="ruby-string">&#39;src0.txt&#39;</span>, <span class="ruby-string">&#39;dest0.txt&#39;</span>, <span class="ruby-value">noop:</span> <span class="ruby-keyword">true</span>, <span class="ruby-value">verbose:</span> <span class="ruby-keyword">true</span>)
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">install</span>(<span class="ruby-string">&#39;src1.txt&#39;</span>, <span class="ruby-string">&#39;dest1.txt&#39;</span>, <span class="ruby-value">noop:</span> <span class="ruby-keyword">true</span>, <span class="ruby-value">verbose:</span> <span class="ruby-keyword">true</span>)
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">install</span>(<span class="ruby-string">&#39;src2.txt&#39;</span>, <span class="ruby-string">&#39;dest2&#39;</span>, <span class="ruby-value">noop:</span> <span class="ruby-keyword">true</span>, <span class="ruby-value">verbose:</span> <span class="ruby-keyword">true</span>)
</pre>

<p>Output:</p>

<pre>install -c src0.txt dest0.txt
install -c src1.txt dest1.txt
install -c src2.txt dest2</pre>
</li></ul>

<p>Related: <a href="FileUtils.html#module-FileUtils-label-Copying">methods for copying</a>.</p>

                              <div class="method-source-code" id="install-source">
            <pre><span class="ruby-comment"># File fileutils.rb, line 1609</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">install</span>(<span class="ruby-identifier">src</span>, <span class="ruby-identifier">dest</span>, <span class="ruby-value">mode:</span> <span class="ruby-keyword">nil</span>, <span class="ruby-value">owner:</span> <span class="ruby-keyword">nil</span>, <span class="ruby-value">group:</span> <span class="ruby-keyword">nil</span>, <span class="ruby-value">preserve:</span> <span class="ruby-keyword">nil</span>,
            <span class="ruby-value">noop:</span> <span class="ruby-keyword">nil</span>, <span class="ruby-value">verbose:</span> <span class="ruby-keyword">nil</span>)
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">verbose</span>
    <span class="ruby-identifier">msg</span> = <span class="ruby-string">+&quot;install -c&quot;</span>
    <span class="ruby-identifier">msg</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-string">&#39; -p&#39;</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">preserve</span>
    <span class="ruby-identifier">msg</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-string">&#39; -m &#39;</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">mode_to_s</span>(<span class="ruby-identifier">mode</span>) <span class="ruby-keyword">if</span> <span class="ruby-identifier">mode</span>
    <span class="ruby-identifier">msg</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-node">&quot; -o #{owner}&quot;</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">owner</span>
    <span class="ruby-identifier">msg</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-node">&quot; -g #{group}&quot;</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">group</span>
    <span class="ruby-identifier">msg</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-string">&#39; &#39;</span> <span class="ruby-operator">&lt;&lt;</span> [<span class="ruby-identifier">src</span>,<span class="ruby-identifier">dest</span>].<span class="ruby-identifier">flatten</span>.<span class="ruby-identifier">join</span>(<span class="ruby-string">&#39; &#39;</span>)
    <span class="ruby-identifier">fu_output_message</span> <span class="ruby-identifier">msg</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">return</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">noop</span>
  <span class="ruby-identifier">uid</span> = <span class="ruby-identifier">fu_get_uid</span>(<span class="ruby-identifier">owner</span>)
  <span class="ruby-identifier">gid</span> = <span class="ruby-identifier">fu_get_gid</span>(<span class="ruby-identifier">group</span>)
  <span class="ruby-identifier">fu_each_src_dest</span>(<span class="ruby-identifier">src</span>, <span class="ruby-identifier">dest</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">s</span>, <span class="ruby-identifier">d</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">st</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">stat</span>(<span class="ruby-identifier">s</span>)
    <span class="ruby-keyword">unless</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">exist?</span>(<span class="ruby-identifier">d</span>) <span class="ruby-keyword">and</span> <span class="ruby-identifier">compare_file</span>(<span class="ruby-identifier">s</span>, <span class="ruby-identifier">d</span>)
      <span class="ruby-identifier">remove_file</span> <span class="ruby-identifier">d</span>, <span class="ruby-keyword">true</span>
      <span class="ruby-keyword">if</span> <span class="ruby-identifier">d</span>.<span class="ruby-identifier">end_with?</span>(<span class="ruby-string">&#39;/&#39;</span>)
        <span class="ruby-identifier">mkdir_p</span> <span class="ruby-identifier">d</span>
        <span class="ruby-identifier">copy_file</span> <span class="ruby-identifier">s</span>, <span class="ruby-identifier">d</span> <span class="ruby-operator">+</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">basename</span>(<span class="ruby-identifier">s</span>)
      <span class="ruby-keyword">else</span>
        <span class="ruby-identifier">mkdir_p</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">expand_path</span>(<span class="ruby-string">&#39;..&#39;</span>, <span class="ruby-identifier">d</span>)
        <span class="ruby-identifier">copy_file</span> <span class="ruby-identifier">s</span>, <span class="ruby-identifier">d</span>
      <span class="ruby-keyword">end</span>
      <span class="ruby-constant">File</span>.<span class="ruby-identifier">utime</span> <span class="ruby-identifier">st</span>.<span class="ruby-identifier">atime</span>, <span class="ruby-identifier">st</span>.<span class="ruby-identifier">mtime</span>, <span class="ruby-identifier">d</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">preserve</span>
      <span class="ruby-constant">File</span>.<span class="ruby-identifier">chmod</span> <span class="ruby-identifier">fu_mode</span>(<span class="ruby-identifier">mode</span>, <span class="ruby-identifier">st</span>), <span class="ruby-identifier">d</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">mode</span>
      <span class="ruby-constant">File</span>.<span class="ruby-identifier">chown</span> <span class="ruby-identifier">uid</span>, <span class="ruby-identifier">gid</span>, <span class="ruby-identifier">d</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">uid</span> <span class="ruby-keyword">or</span> <span class="ruby-identifier">gid</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-link" class="method-detail method-alias">
                            <div class="method-heading">
                              <span class="method-name">link</span><span
                                class="method-args">(src, dest, force: nil, noop: nil, verbose: nil)</span>
                            </div>

                            <div class="method-description">
                              

                            </div>


                            <div class="aliases">
                              Alias for: <a href="FileUtils.html#method-i-ln">ln</a>
                            </div>
                          </div>

                  <div id="method-i-link_entry" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">link_entry</span><span
                                class="method-args">(src, dest, dereference_root = false, remove_destination = false)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Creates <a href="https://en.wikipedia.org/wiki/Hard_link">hard links</a>; returns <code>nil</code>.</p>

<p>Arguments <code>src</code> and <code>dest</code> should be <a href="FileUtils.html#module-FileUtils-label-Path+Arguments">interpretable as paths</a>.</p>

<p>If <code>src</code> is the path to a file and <code>dest</code> does not exist, creates a hard link at <code>dest</code> pointing to <code>src</code>:</p>

<pre class="ruby"><span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">touch</span>(<span class="ruby-string">&#39;src0.txt&#39;</span>)
<span class="ruby-constant">File</span>.<span class="ruby-identifier">exist?</span>(<span class="ruby-string">&#39;dest0.txt&#39;</span>) <span class="ruby-comment"># =&gt; false</span>
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">link_entry</span>(<span class="ruby-string">&#39;src0.txt&#39;</span>, <span class="ruby-string">&#39;dest0.txt&#39;</span>)
<span class="ruby-constant">File</span>.<span class="ruby-identifier">file?</span>(<span class="ruby-string">&#39;dest0.txt&#39;</span>)  <span class="ruby-comment"># =&gt; true</span>
</pre>

<p>If <code>src</code> is the path to a directory and <code>dest</code> does not exist, recursively creates hard links at <code>dest</code> pointing to paths in <code>src</code>:</p>

<pre class="ruby"><span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">mkdir_p</span>([<span class="ruby-string">&#39;src1/dir0&#39;</span>, <span class="ruby-string">&#39;src1/dir1&#39;</span>])
<span class="ruby-identifier">src_file_paths</span> = [
  <span class="ruby-string">&#39;src1/dir0/t0.txt&#39;</span>,
  <span class="ruby-string">&#39;src1/dir0/t1.txt&#39;</span>,
  <span class="ruby-string">&#39;src1/dir1/t2.txt&#39;</span>,
  <span class="ruby-string">&#39;src1/dir1/t3.txt&#39;</span>,
  ]
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">touch</span>(<span class="ruby-identifier">src_file_paths</span>)
<span class="ruby-constant">File</span>.<span class="ruby-identifier">directory?</span>(<span class="ruby-string">&#39;dest1&#39;</span>)        <span class="ruby-comment"># =&gt; true</span>
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">link_entry</span>(<span class="ruby-string">&#39;src1&#39;</span>, <span class="ruby-string">&#39;dest1&#39;</span>)
<span class="ruby-constant">File</span>.<span class="ruby-identifier">file?</span>(<span class="ruby-string">&#39;dest1/dir0/t0.txt&#39;</span>) <span class="ruby-comment"># =&gt; true</span>
<span class="ruby-constant">File</span>.<span class="ruby-identifier">file?</span>(<span class="ruby-string">&#39;dest1/dir0/t1.txt&#39;</span>) <span class="ruby-comment"># =&gt; true</span>
<span class="ruby-constant">File</span>.<span class="ruby-identifier">file?</span>(<span class="ruby-string">&#39;dest1/dir1/t2.txt&#39;</span>) <span class="ruby-comment"># =&gt; true</span>
<span class="ruby-constant">File</span>.<span class="ruby-identifier">file?</span>(<span class="ruby-string">&#39;dest1/dir1/t3.txt&#39;</span>) <span class="ruby-comment"># =&gt; true</span>
</pre>

<p>Keyword arguments:</p>
<ul><li>
<p><code>dereference_root: true</code> - dereferences <code>src</code> if it is a symbolic link.</p>
</li><li>
<p><code>remove_destination: true</code> - removes <code>dest</code> before creating links.</p>
</li></ul>

<p>Raises an exception if <code>dest</code> is the path to an existing file or directory and keyword argument <code>remove_destination: true</code> is not given.</p>

<p>Related: <a href="FileUtils.html#method-c-ln"><code>FileUtils.ln</code></a> (has different options).</p>

                              <div class="method-source-code" id="link_entry-source">
            <pre><span class="ruby-comment"># File fileutils.rb, line 812</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">link_entry</span>(<span class="ruby-identifier">src</span>, <span class="ruby-identifier">dest</span>, <span class="ruby-identifier">dereference_root</span> = <span class="ruby-keyword">false</span>, <span class="ruby-identifier">remove_destination</span> = <span class="ruby-keyword">false</span>)
  <span class="ruby-constant">Entry_</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">src</span>, <span class="ruby-keyword">nil</span>, <span class="ruby-identifier">dereference_root</span>).<span class="ruby-identifier">traverse</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">ent</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">destent</span> = <span class="ruby-constant">Entry_</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">dest</span>, <span class="ruby-identifier">ent</span>.<span class="ruby-identifier">rel</span>, <span class="ruby-keyword">false</span>)
    <span class="ruby-constant">File</span>.<span class="ruby-identifier">unlink</span> <span class="ruby-identifier">destent</span>.<span class="ruby-identifier">path</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">remove_destination</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">file?</span>(<span class="ruby-identifier">destent</span>.<span class="ruby-identifier">path</span>)
    <span class="ruby-identifier">ent</span>.<span class="ruby-identifier">link</span> <span class="ruby-identifier">destent</span>.<span class="ruby-identifier">path</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-ln" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">ln</span><span
                                class="method-args">(src, dest, force: nil, noop: nil, verbose: nil)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Creates <a href="https://en.wikipedia.org/wiki/Hard_link">hard links</a>.</p>

<p>Arguments <code>src</code> (a single path or an array of paths) and <code>dest</code> (a single path) should be <a href="FileUtils.html#module-FileUtils-label-Path+Arguments">interpretable as paths</a>.</p>

<p>When <code>src</code> is the path to an existing file and <code>dest</code> is the path to a non-existent file, creates a hard link at <code>dest</code> pointing to <code>src</code>; returns zero:</p>

<pre class="ruby"><span class="ruby-constant">Dir</span>.<span class="ruby-identifier">children</span>(<span class="ruby-string">&#39;tmp0/&#39;</span>)                    <span class="ruby-comment"># =&gt; [&quot;t.txt&quot;]</span>
<span class="ruby-constant">Dir</span>.<span class="ruby-identifier">children</span>(<span class="ruby-string">&#39;tmp1/&#39;</span>)                    <span class="ruby-comment"># =&gt; []</span>
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">ln</span>(<span class="ruby-string">&#39;tmp0/t.txt&#39;</span>, <span class="ruby-string">&#39;tmp1/t.lnk&#39;</span>) <span class="ruby-comment"># =&gt; 0</span>
<span class="ruby-constant">Dir</span>.<span class="ruby-identifier">children</span>(<span class="ruby-string">&#39;tmp1/&#39;</span>)                    <span class="ruby-comment"># =&gt; [&quot;t.lnk&quot;]</span>
</pre>

<p>When <code>src</code> is the path to an existing file and <code>dest</code> is the path to an existing directory, creates a hard link at <code>dest/src</code> pointing to <code>src</code>; returns zero:</p>

<pre class="ruby"><span class="ruby-constant">Dir</span>.<span class="ruby-identifier">children</span>(<span class="ruby-string">&#39;tmp2&#39;</span>)               <span class="ruby-comment"># =&gt; [&quot;t.dat&quot;]</span>
<span class="ruby-constant">Dir</span>.<span class="ruby-identifier">children</span>(<span class="ruby-string">&#39;tmp3&#39;</span>)               <span class="ruby-comment"># =&gt; []</span>
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">ln</span>(<span class="ruby-string">&#39;tmp2/t.dat&#39;</span>, <span class="ruby-string">&#39;tmp3&#39;</span>) <span class="ruby-comment"># =&gt; 0</span>
<span class="ruby-constant">Dir</span>.<span class="ruby-identifier">children</span>(<span class="ruby-string">&#39;tmp3&#39;</span>)               <span class="ruby-comment"># =&gt; [&quot;t.dat&quot;]</span>
</pre>

<p>When <code>src</code> is an array of paths to existing files and <code>dest</code> is the path to an existing directory, then for each path <code>target</code> in <code>src</code>, creates a hard link at <code>dest/target</code> pointing to <code>target</code>; returns <code>src</code>:</p>

<pre class="ruby"><span class="ruby-constant">Dir</span>.<span class="ruby-identifier">children</span>(<span class="ruby-string">&#39;tmp4/&#39;</span>)                               <span class="ruby-comment"># =&gt; []</span>
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">ln</span>([<span class="ruby-string">&#39;tmp0/t.txt&#39;</span>, <span class="ruby-string">&#39;tmp2/t.dat&#39;</span>], <span class="ruby-string">&#39;tmp4/&#39;</span>) <span class="ruby-comment"># =&gt; [&quot;tmp0/t.txt&quot;, &quot;tmp2/t.dat&quot;]</span>
<span class="ruby-constant">Dir</span>.<span class="ruby-identifier">children</span>(<span class="ruby-string">&#39;tmp4/&#39;</span>)                               <span class="ruby-comment"># =&gt; [&quot;t.dat&quot;, &quot;t.txt&quot;]</span>
</pre>

<p>Keyword arguments:</p>
<ul><li>
<p><code>force: true</code> - overwrites <code>dest</code> if it exists.</p>
</li><li>
<p><code>noop: true</code> - does not create links.</p>
</li><li>
<p><code>verbose: true</code> - prints an equivalent command:</p>

<pre class="ruby"><span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">ln</span>(<span class="ruby-string">&#39;tmp0/t.txt&#39;</span>, <span class="ruby-string">&#39;tmp1/t.lnk&#39;</span>, <span class="ruby-value">verbose:</span> <span class="ruby-keyword">true</span>)
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">ln</span>(<span class="ruby-string">&#39;tmp2/t.dat&#39;</span>, <span class="ruby-string">&#39;tmp3&#39;</span>, <span class="ruby-value">verbose:</span> <span class="ruby-keyword">true</span>)
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">ln</span>([<span class="ruby-string">&#39;tmp0/t.txt&#39;</span>, <span class="ruby-string">&#39;tmp2/t.dat&#39;</span>], <span class="ruby-string">&#39;tmp4/&#39;</span>, <span class="ruby-value">verbose:</span> <span class="ruby-keyword">true</span>)
</pre>

<p>Output:</p>

<pre>ln tmp0/t.txt tmp1/t.lnk
ln tmp2/t.dat tmp3
ln tmp0/t.txt tmp2/t.dat tmp4/</pre>
</li></ul>

<p>Raises an exception if <code>dest</code> is the path to an existing file and keyword argument <code>force</code> is not <code>true</code>.</p>

<p>Related: <a href="FileUtils.html#method-c-link_entry"><code>FileUtils.link_entry</code></a> (has different options).</p>

                              <div class="method-source-code" id="ln-source">
            <pre><span class="ruby-comment"># File fileutils.rb, line 516</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">ln</span>(<span class="ruby-identifier">src</span>, <span class="ruby-identifier">dest</span>, <span class="ruby-value">force:</span> <span class="ruby-keyword">nil</span>, <span class="ruby-value">noop:</span> <span class="ruby-keyword">nil</span>, <span class="ruby-value">verbose:</span> <span class="ruby-keyword">nil</span>)
  <span class="ruby-identifier">fu_output_message</span> <span class="ruby-node">&quot;ln#{force ? &#39; -f&#39; : &#39;&#39;} #{[src,dest].flatten.join &#39; &#39;}&quot;</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">verbose</span>
  <span class="ruby-keyword">return</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">noop</span>
  <span class="ruby-identifier">fu_each_src_dest0</span>(<span class="ruby-identifier">src</span>, <span class="ruby-identifier">dest</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">s</span>,<span class="ruby-identifier">d</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">remove_file</span> <span class="ruby-identifier">d</span>, <span class="ruby-keyword">true</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">force</span>
    <span class="ruby-constant">File</span>.<span class="ruby-identifier">link</span> <span class="ruby-identifier">s</span>, <span class="ruby-identifier">d</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>

                            <div class="aliases">
                              Also aliased as: <a href="FileUtils.html#method-i-link">link</a>
                            </div>

                          </div>

                  <div id="method-i-ln_s" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">ln_s</span><span
                                class="method-args">(src, dest, force: nil, relative: false, target_directory: true, noop: nil, verbose: nil)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Creates <a href="https://en.wikipedia.org/wiki/Symbolic_link">symbolic links</a>.</p>

<p>Arguments <code>src</code> (a single path or an array of paths) and <code>dest</code> (a single path) should be <a href="FileUtils.html#module-FileUtils-label-Path+Arguments">interpretable as paths</a>.</p>

<p>If <code>src</code> is the path to an existing file:</p>
<ul><li>
<p>When <code>dest</code> is the path to a non-existent file, creates a symbolic link at <code>dest</code> pointing to <code>src</code>:</p>

<pre class="ruby"><span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">touch</span>(<span class="ruby-string">&#39;src0.txt&#39;</span>)
<span class="ruby-constant">File</span>.<span class="ruby-identifier">exist?</span>(<span class="ruby-string">&#39;dest0.txt&#39;</span>)   <span class="ruby-comment"># =&gt; false</span>
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">ln_s</span>(<span class="ruby-string">&#39;src0.txt&#39;</span>, <span class="ruby-string">&#39;dest0.txt&#39;</span>)
<span class="ruby-constant">File</span>.<span class="ruby-identifier">symlink?</span>(<span class="ruby-string">&#39;dest0.txt&#39;</span>) <span class="ruby-comment"># =&gt; true</span>
</pre>
</li><li>
<p>When <code>dest</code> is the path to an existing file, creates a symbolic link at <code>dest</code> pointing to <code>src</code> if and only if keyword argument <code>force: true</code> is given (raises an exception otherwise):</p>

<pre class="ruby"><span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">touch</span>(<span class="ruby-string">&#39;src1.txt&#39;</span>)
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">touch</span>(<span class="ruby-string">&#39;dest1.txt&#39;</span>)
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">ln_s</span>(<span class="ruby-string">&#39;src1.txt&#39;</span>, <span class="ruby-string">&#39;dest1.txt&#39;</span>, <span class="ruby-value">force:</span> <span class="ruby-keyword">true</span>)
<span class="ruby-constant">FileTest</span>.<span class="ruby-identifier">symlink?</span>(<span class="ruby-string">&#39;dest1.txt&#39;</span>) <span class="ruby-comment"># =&gt; true</span>

<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">ln_s</span>(<span class="ruby-string">&#39;src1.txt&#39;</span>, <span class="ruby-string">&#39;dest1.txt&#39;</span>) <span class="ruby-comment"># Raises Errno::EEXIST.</span>
</pre>
</li></ul>

<p>If <code>dest</code> is the path to a directory, creates a symbolic link at <code>dest/src</code> pointing to <code>src</code>:</p>

<pre class="ruby"><span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">touch</span>(<span class="ruby-string">&#39;src2.txt&#39;</span>)
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">mkdir</span>(<span class="ruby-string">&#39;destdir2&#39;</span>)
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">ln_s</span>(<span class="ruby-string">&#39;src2.txt&#39;</span>, <span class="ruby-string">&#39;destdir2&#39;</span>)
<span class="ruby-constant">File</span>.<span class="ruby-identifier">symlink?</span>(<span class="ruby-string">&#39;destdir2/src2.txt&#39;</span>) <span class="ruby-comment"># =&gt; true</span>
</pre>

<p>If <code>src</code> is an array of paths to existing files and <code>dest</code> is a directory, for each child <code>child</code> in <code>src</code> creates a symbolic link <code>dest/child</code> pointing to <code>child</code>:</p>

<pre class="ruby"><span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">mkdir</span>(<span class="ruby-string">&#39;srcdir3&#39;</span>)
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">touch</span>(<span class="ruby-string">&#39;srcdir3/src0.txt&#39;</span>)
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">touch</span>(<span class="ruby-string">&#39;srcdir3/src1.txt&#39;</span>)
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">mkdir</span>(<span class="ruby-string">&#39;destdir3&#39;</span>)
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">ln_s</span>([<span class="ruby-string">&#39;srcdir3/src0.txt&#39;</span>, <span class="ruby-string">&#39;srcdir3/src1.txt&#39;</span>], <span class="ruby-string">&#39;destdir3&#39;</span>)
<span class="ruby-constant">File</span>.<span class="ruby-identifier">symlink?</span>(<span class="ruby-string">&#39;destdir3/src0.txt&#39;</span>) <span class="ruby-comment"># =&gt; true</span>
<span class="ruby-constant">File</span>.<span class="ruby-identifier">symlink?</span>(<span class="ruby-string">&#39;destdir3/src1.txt&#39;</span>) <span class="ruby-comment"># =&gt; true</span>
</pre>

<p>Keyword arguments:</p>
<ul><li>
<p><code>force: true</code> - overwrites <code>dest</code> if it exists.</p>
</li><li>
<p><code>relative: false</code> - create links relative to <code>dest</code>.</p>
</li><li>
<p><code>noop: true</code> - does not create links.</p>
</li><li>
<p><code>verbose: true</code> - prints an equivalent command:</p>

<pre class="ruby"><span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">ln_s</span>(<span class="ruby-string">&#39;src0.txt&#39;</span>, <span class="ruby-string">&#39;dest0.txt&#39;</span>, <span class="ruby-value">noop:</span> <span class="ruby-keyword">true</span>, <span class="ruby-value">verbose:</span> <span class="ruby-keyword">true</span>)
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">ln_s</span>(<span class="ruby-string">&#39;src1.txt&#39;</span>, <span class="ruby-string">&#39;destdir1&#39;</span>, <span class="ruby-value">noop:</span> <span class="ruby-keyword">true</span>, <span class="ruby-value">verbose:</span> <span class="ruby-keyword">true</span>)
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">ln_s</span>(<span class="ruby-string">&#39;src2.txt&#39;</span>, <span class="ruby-string">&#39;dest2.txt&#39;</span>, <span class="ruby-value">force:</span> <span class="ruby-keyword">true</span>, <span class="ruby-value">noop:</span> <span class="ruby-keyword">true</span>, <span class="ruby-value">verbose:</span> <span class="ruby-keyword">true</span>)
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">ln_s</span>([<span class="ruby-string">&#39;srcdir3/src0.txt&#39;</span>, <span class="ruby-string">&#39;srcdir3/src1.txt&#39;</span>], <span class="ruby-string">&#39;destdir3&#39;</span>, <span class="ruby-value">noop:</span> <span class="ruby-keyword">true</span>, <span class="ruby-value">verbose:</span> <span class="ruby-keyword">true</span>)
</pre>

<p>Output:</p>

<pre>ln -s src0.txt dest0.txt
ln -s src1.txt destdir1
ln -sf src2.txt dest2.txt
ln -s srcdir3/src0.txt srcdir3/src1.txt destdir3</pre>
</li></ul>

<p>Related: <a href="FileUtils.html#method-c-ln_sf"><code>FileUtils.ln_sf</code></a>.</p>

                              <div class="method-source-code" id="ln_s-source">
            <pre><span class="ruby-comment"># File fileutils.rb, line 706</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">ln_s</span>(<span class="ruby-identifier">src</span>, <span class="ruby-identifier">dest</span>, <span class="ruby-value">force:</span> <span class="ruby-keyword">nil</span>, <span class="ruby-value">relative:</span> <span class="ruby-keyword">false</span>, <span class="ruby-value">target_directory:</span> <span class="ruby-keyword">true</span>, <span class="ruby-value">noop:</span> <span class="ruby-keyword">nil</span>, <span class="ruby-value">verbose:</span> <span class="ruby-keyword">nil</span>)
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">relative</span>
    <span class="ruby-keyword">return</span> <span class="ruby-identifier">ln_sr</span>(<span class="ruby-identifier">src</span>, <span class="ruby-identifier">dest</span>, <span class="ruby-value">force:</span> <span class="ruby-identifier">force</span>, <span class="ruby-value">noop:</span> <span class="ruby-identifier">noop</span>, <span class="ruby-value">verbose:</span> <span class="ruby-identifier">verbose</span>)
  <span class="ruby-keyword">end</span>
  <span class="ruby-identifier">fu_output_message</span> <span class="ruby-node">&quot;ln -s#{force ? &#39;f&#39; : &#39;&#39;} #{[src,dest].flatten.join &#39; &#39;}&quot;</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">verbose</span>
  <span class="ruby-keyword">return</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">noop</span>
  <span class="ruby-identifier">fu_each_src_dest0</span>(<span class="ruby-identifier">src</span>, <span class="ruby-identifier">dest</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">s</span>,<span class="ruby-identifier">d</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">remove_file</span> <span class="ruby-identifier">d</span>, <span class="ruby-keyword">true</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">force</span>
    <span class="ruby-constant">File</span>.<span class="ruby-identifier">symlink</span> <span class="ruby-identifier">s</span>, <span class="ruby-identifier">d</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>

                            <div class="aliases">
                              Also aliased as: <a href="FileUtils.html#method-i-symlink">symlink</a>
                            </div>

                          </div>

                  <div id="method-i-ln_sf" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">ln_sf</span><span
                                class="method-args">(src, dest, noop: nil, verbose: nil)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Like <a href="FileUtils.html#method-c-ln_s"><code>FileUtils.ln_s</code></a>, but always with keyword argument <code>force: true</code> given.</p>

                              <div class="method-source-code" id="ln_sf-source">
            <pre><span class="ruby-comment"># File fileutils.rb, line 724</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">ln_sf</span>(<span class="ruby-identifier">src</span>, <span class="ruby-identifier">dest</span>, <span class="ruby-value">noop:</span> <span class="ruby-keyword">nil</span>, <span class="ruby-value">verbose:</span> <span class="ruby-keyword">nil</span>)
  <span class="ruby-identifier">ln_s</span> <span class="ruby-identifier">src</span>, <span class="ruby-identifier">dest</span>, <span class="ruby-value">force:</span> <span class="ruby-keyword">true</span>, <span class="ruby-value">noop:</span> <span class="ruby-identifier">noop</span>, <span class="ruby-value">verbose:</span> <span class="ruby-identifier">verbose</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-ln_sr" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">ln_sr</span><span
                                class="method-args">(src, dest, target_directory: true, force: nil, noop: nil, verbose: nil)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Like <a href="FileUtils.html#method-c-ln_s"><code>FileUtils.ln_s</code></a>, but create links relative to <code>dest</code>.</p>

                              <div class="method-source-code" id="ln_sr-source">
            <pre><span class="ruby-comment"># File fileutils.rb, line 731</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">ln_sr</span>(<span class="ruby-identifier">src</span>, <span class="ruby-identifier">dest</span>, <span class="ruby-value">target_directory:</span> <span class="ruby-keyword">true</span>, <span class="ruby-value">force:</span> <span class="ruby-keyword">nil</span>, <span class="ruby-value">noop:</span> <span class="ruby-keyword">nil</span>, <span class="ruby-value">verbose:</span> <span class="ruby-keyword">nil</span>)
  <span class="ruby-identifier">options</span> = <span class="ruby-node">&quot;#{force ? &#39;f&#39; : &#39;&#39;}#{target_directory ? &#39;&#39; : &#39;T&#39;}&quot;</span>
  <span class="ruby-identifier">dest</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">path</span>(<span class="ruby-identifier">dest</span>)
  <span class="ruby-identifier">srcs</span> = <span class="ruby-constant">Array</span>(<span class="ruby-identifier">src</span>)
  <span class="ruby-identifier">link</span> = <span class="ruby-identifier">proc</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">s</span>, <span class="ruby-identifier">target_dir_p</span> = <span class="ruby-keyword">true</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">s</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">path</span>(<span class="ruby-identifier">s</span>)
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">target_dir_p</span>
      <span class="ruby-identifier">d</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-identifier">destdirs</span> = <span class="ruby-identifier">dest</span>, <span class="ruby-constant">File</span>.<span class="ruby-identifier">basename</span>(<span class="ruby-identifier">s</span>))
    <span class="ruby-keyword">else</span>
      <span class="ruby-identifier">destdirs</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">dirname</span>(<span class="ruby-identifier">d</span> = <span class="ruby-identifier">dest</span>)
    <span class="ruby-keyword">end</span>
    <span class="ruby-identifier">destdirs</span> = <span class="ruby-identifier">fu_split_path</span>(<span class="ruby-constant">File</span>.<span class="ruby-identifier">realpath</span>(<span class="ruby-identifier">destdirs</span>))
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">fu_starting_path?</span>(<span class="ruby-identifier">s</span>)
      <span class="ruby-identifier">srcdirs</span> = <span class="ruby-identifier">fu_split_path</span>((<span class="ruby-constant">File</span>.<span class="ruby-identifier">realdirpath</span>(<span class="ruby-identifier">s</span>) <span class="ruby-keyword">rescue</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">expand_path</span>(<span class="ruby-identifier">s</span>)))
      <span class="ruby-identifier">base</span> = <span class="ruby-identifier">fu_relative_components_from</span>(<span class="ruby-identifier">srcdirs</span>, <span class="ruby-identifier">destdirs</span>)
      <span class="ruby-identifier">s</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">base</span>)
    <span class="ruby-keyword">else</span>
      <span class="ruby-identifier">srcdirs</span> = <span class="ruby-identifier">fu_clean_components</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">fu_split_path</span>(<span class="ruby-identifier">s</span>))
      <span class="ruby-identifier">base</span> = <span class="ruby-identifier">fu_relative_components_from</span>(<span class="ruby-identifier">fu_split_path</span>(<span class="ruby-constant">Dir</span>.<span class="ruby-identifier">pwd</span>), <span class="ruby-identifier">destdirs</span>)
      <span class="ruby-keyword">while</span> <span class="ruby-identifier">srcdirs</span>.<span class="ruby-identifier">first</span>&amp;. <span class="ruby-identifier">==</span> <span class="ruby-string">&quot;..&quot;</span> <span class="ruby-keyword">and</span> <span class="ruby-identifier">base</span>.<span class="ruby-identifier">last</span>&amp;.<span class="ruby-identifier">!=</span>(<span class="ruby-string">&quot;..&quot;</span>) <span class="ruby-keyword">and</span> <span class="ruby-operator">!</span><span class="ruby-identifier">fu_starting_path?</span>(<span class="ruby-identifier">base</span>.<span class="ruby-identifier">last</span>)
        <span class="ruby-identifier">srcdirs</span>.<span class="ruby-identifier">shift</span>
        <span class="ruby-identifier">base</span>.<span class="ruby-identifier">pop</span>
      <span class="ruby-keyword">end</span>
      <span class="ruby-identifier">s</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">base</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">srcdirs</span>)
    <span class="ruby-keyword">end</span>
    <span class="ruby-identifier">fu_output_message</span> <span class="ruby-node">&quot;ln -s#{options} #{s} #{d}&quot;</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">verbose</span>
    <span class="ruby-keyword">next</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">noop</span>
    <span class="ruby-identifier">remove_file</span> <span class="ruby-identifier">d</span>, <span class="ruby-keyword">true</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">force</span>
    <span class="ruby-constant">File</span>.<span class="ruby-identifier">symlink</span> <span class="ruby-identifier">s</span>, <span class="ruby-identifier">d</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">case</span> <span class="ruby-identifier">srcs</span>.<span class="ruby-identifier">size</span>
  <span class="ruby-keyword">when</span> <span class="ruby-value">0</span>
  <span class="ruby-keyword">when</span> <span class="ruby-value">1</span>
    <span class="ruby-identifier">link</span>[<span class="ruby-identifier">srcs</span>[<span class="ruby-value">0</span>], <span class="ruby-identifier">target_directory</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">directory?</span>(<span class="ruby-identifier">dest</span>)]
  <span class="ruby-keyword">else</span>
    <span class="ruby-identifier">srcs</span>.<span class="ruby-identifier">each</span>(<span class="ruby-operator">&amp;</span><span class="ruby-identifier">link</span>)
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-makedirs" class="method-detail method-alias">
                            <div class="method-heading">
                              <span class="method-name">makedirs</span><span
                                class="method-args">(list, mode: nil, noop: nil, verbose: nil)</span>
                            </div>

                            <div class="method-description">
                              

                            </div>


                            <div class="aliases">
                              Alias for: <a href="FileUtils.html#method-i-mkdir_p">mkdir_p</a>
                            </div>
                          </div>

                  <div id="method-i-mkdir" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">mkdir</span><span
                                class="method-args">(list, mode: nil, noop: nil, verbose: nil)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Creates directories at the paths in the given <code>list</code> (a single path or an array of paths); returns <code>list</code> if it is an array, <code>[list]</code> otherwise.</p>

<p>Argument <code>list</code> or its elements should be <a href="FileUtils.html#module-FileUtils-label-Path+Arguments">interpretable as paths</a>.</p>

<p>With no keyword arguments, creates a directory at each <code>path</code> in <code>list</code> by calling: <code>Dir.mkdir(path, mode)</code>; see Dir.mkdir:</p>

<pre class="ruby"><span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">mkdir</span>(<span class="ruby-node">%w[tmp0 tmp1]</span>) <span class="ruby-comment"># =&gt; [&quot;tmp0&quot;, &quot;tmp1&quot;]</span>
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">mkdir</span>(<span class="ruby-string">&#39;tmp4&#39;</span>)        <span class="ruby-comment"># =&gt; [&quot;tmp4&quot;]</span>
</pre>

<p>Keyword arguments:</p>
<ul><li>
<p><code>mode: <em>mode</em></code> - also calls <code>File.chmod(mode, path)</code>; see File.chmod.</p>
</li><li>
<p><code>noop: true</code> - does not create directories.</p>
</li><li>
<p><code>verbose: true</code> - prints an equivalent command:</p>

<pre class="ruby"><span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">mkdir</span>(<span class="ruby-node">%w[tmp0 tmp1]</span>, <span class="ruby-value">verbose:</span> <span class="ruby-keyword">true</span>)
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">mkdir</span>(<span class="ruby-node">%w[tmp2 tmp3]</span>, <span class="ruby-value">mode:</span> <span class="ruby-value">0700</span>, <span class="ruby-value">verbose:</span> <span class="ruby-keyword">true</span>)
</pre>

<p>Output:</p>

<pre>mkdir tmp0 tmp1
mkdir -m 700 tmp2 tmp3</pre>
</li></ul>

<p>Raises an exception if any path points to an existing file or directory, or if for any reason a directory cannot be created.</p>

<p>Related: <a href="FileUtils.html#method-c-mkdir_p"><code>FileUtils.mkdir_p</code></a>.</p>

                              <div class="method-source-code" id="mkdir-source">
            <pre><span class="ruby-comment"># File fileutils.rb, line 316</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">mkdir</span>(<span class="ruby-identifier">list</span>, <span class="ruby-value">mode:</span> <span class="ruby-keyword">nil</span>, <span class="ruby-value">noop:</span> <span class="ruby-keyword">nil</span>, <span class="ruby-value">verbose:</span> <span class="ruby-keyword">nil</span>)
  <span class="ruby-identifier">list</span> = <span class="ruby-identifier">fu_list</span>(<span class="ruby-identifier">list</span>)
  <span class="ruby-identifier">fu_output_message</span> <span class="ruby-node">&quot;mkdir #{mode ? (&#39;-m %03o &#39; % mode) : &#39;&#39;}#{list.join &#39; &#39;}&quot;</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">verbose</span>
  <span class="ruby-keyword">return</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">noop</span>

  <span class="ruby-identifier">list</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">dir</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">fu_mkdir</span> <span class="ruby-identifier">dir</span>, <span class="ruby-identifier">mode</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-mkdir_p" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">mkdir_p</span><span
                                class="method-args">(list, mode: nil, noop: nil, verbose: nil)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Creates directories at the paths in the given <code>list</code> (a single path or an array of paths), also creating ancestor directories as needed; returns <code>list</code> if it is an array, <code>[list]</code> otherwise.</p>

<p>Argument <code>list</code> or its elements should be <a href="FileUtils.html#module-FileUtils-label-Path+Arguments">interpretable as paths</a>.</p>

<p>With no keyword arguments, creates a directory at each <code>path</code> in <code>list</code>, along with any needed ancestor directories, by calling: <code>Dir.mkdir(path, mode)</code>; see Dir.mkdir:</p>

<pre class="ruby"><span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">mkdir_p</span>(<span class="ruby-node">%w[tmp0/tmp1 tmp2/tmp3]</span>) <span class="ruby-comment"># =&gt; [&quot;tmp0/tmp1&quot;, &quot;tmp2/tmp3&quot;]</span>
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">mkdir_p</span>(<span class="ruby-string">&#39;tmp4/tmp5&#39;</span>)             <span class="ruby-comment"># =&gt; [&quot;tmp4/tmp5&quot;]</span>
</pre>

<p>Keyword arguments:</p>
<ul><li>
<p><code>mode: <em>mode</em></code> - also calls <code>File.chmod(mode, path)</code>; see File.chmod.</p>
</li><li>
<p><code>noop: true</code> - does not create directories.</p>
</li><li>
<p><code>verbose: true</code> - prints an equivalent command:</p>

<pre class="ruby"><span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">mkdir_p</span>(<span class="ruby-node">%w[tmp0 tmp1]</span>, <span class="ruby-value">verbose:</span> <span class="ruby-keyword">true</span>)
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">mkdir_p</span>(<span class="ruby-node">%w[tmp2 tmp3]</span>, <span class="ruby-value">mode:</span> <span class="ruby-value">0700</span>, <span class="ruby-value">verbose:</span> <span class="ruby-keyword">true</span>)
</pre>

<p>Output:</p>

<pre>mkdir -p tmp0 tmp1
mkdir -p -m 700 tmp2 tmp3</pre>
</li></ul>

<p>Raises an exception if for any reason a directory cannot be created.</p>

<p><a href="FileUtils.html#method-c-mkpath"><code>FileUtils.mkpath</code></a> and <a href="FileUtils.html#method-c-makedirs"><code>FileUtils.makedirs</code></a> are aliases for <a href="FileUtils.html#method-c-mkdir_p"><code>FileUtils.mkdir_p</code></a>.</p>

<p>Related: <a href="FileUtils.html#method-c-mkdir"><code>FileUtils.mkdir</code></a>.</p>

                              <div class="method-source-code" id="mkdir_p-source">
            <pre><span class="ruby-comment"># File fileutils.rb, line 365</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">mkdir_p</span>(<span class="ruby-identifier">list</span>, <span class="ruby-value">mode:</span> <span class="ruby-keyword">nil</span>, <span class="ruby-value">noop:</span> <span class="ruby-keyword">nil</span>, <span class="ruby-value">verbose:</span> <span class="ruby-keyword">nil</span>)
  <span class="ruby-identifier">list</span> = <span class="ruby-identifier">fu_list</span>(<span class="ruby-identifier">list</span>)
  <span class="ruby-identifier">fu_output_message</span> <span class="ruby-node">&quot;mkdir -p #{mode ? (&#39;-m %03o &#39; % mode) : &#39;&#39;}#{list.join &#39; &#39;}&quot;</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">verbose</span>
  <span class="ruby-keyword">return</span> <span class="ruby-operator">*</span><span class="ruby-identifier">list</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">noop</span>

  <span class="ruby-identifier">list</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">item</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">path</span> = <span class="ruby-identifier">remove_trailing_slash</span>(<span class="ruby-identifier">item</span>)

    <span class="ruby-identifier">stack</span> = []
    <span class="ruby-keyword">until</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">directory?</span>(<span class="ruby-identifier">path</span>) <span class="ruby-operator">||</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">dirname</span>(<span class="ruby-identifier">path</span>) <span class="ruby-operator">==</span> <span class="ruby-identifier">path</span>
      <span class="ruby-identifier">stack</span>.<span class="ruby-identifier">push</span> <span class="ruby-identifier">path</span>
      <span class="ruby-identifier">path</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">dirname</span>(<span class="ruby-identifier">path</span>)
    <span class="ruby-keyword">end</span>
    <span class="ruby-identifier">stack</span>.<span class="ruby-identifier">reverse_each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">dir</span><span class="ruby-operator">|</span>
      <span class="ruby-keyword">begin</span>
        <span class="ruby-identifier">fu_mkdir</span> <span class="ruby-identifier">dir</span>, <span class="ruby-identifier">mode</span>
      <span class="ruby-keyword">rescue</span> <span class="ruby-constant">SystemCallError</span>
        <span class="ruby-identifier">raise</span> <span class="ruby-keyword">unless</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">directory?</span>(<span class="ruby-identifier">dir</span>)
      <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-keyword">return</span> <span class="ruby-operator">*</span><span class="ruby-identifier">list</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>

                            <div class="aliases">
                              Also aliased as: <a href="FileUtils.html#method-i-mkpath">mkpath</a>, <a href="FileUtils.html#method-i-makedirs">makedirs</a>
                            </div>

                          </div>

                  <div id="method-i-mkpath" class="method-detail method-alias">
                            <div class="method-heading">
                              <span class="method-name">mkpath</span><span
                                class="method-args">(list, mode: nil, noop: nil, verbose: nil)</span>
                            </div>

                            <div class="method-description">
                              

                            </div>


                            <div class="aliases">
                              Alias for: <a href="FileUtils.html#method-i-mkdir_p">mkdir_p</a>
                            </div>
                          </div>

                  <div id="method-i-move" class="method-detail method-alias">
                            <div class="method-heading">
                              <span class="method-name">move</span><span
                                class="method-args">(src, dest, force: nil, noop: nil, verbose: nil, secure: nil)</span>
                            </div>

                            <div class="method-description">
                              

                            </div>


                            <div class="aliases">
                              Alias for: <a href="FileUtils.html#method-i-mv">mv</a>
                            </div>
                          </div>

                  <div id="method-i-mv" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">mv</span><span
                                class="method-args">(src, dest, force: nil, noop: nil, verbose: nil, secure: nil)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Moves entries.</p>

<p>Arguments <code>src</code> (a single path or an array of paths) and <code>dest</code> (a single path) should be <a href="FileUtils.html#module-FileUtils-label-Path+Arguments">interpretable as paths</a>.</p>

<p>If <code>src</code> and <code>dest</code> are on different file systems, first copies, then removes <code>src</code>.</p>

<p>May cause a local vulnerability if not called with keyword argument <code>secure: true</code>; see <a href="FileUtils.html#module-FileUtils-label-Avoiding+the+TOCTTOU+Vulnerability">Avoiding the TOCTTOU Vulnerability</a>.</p>

<p>If <code>src</code> is the path to a single file or directory and <code>dest</code> does not exist, moves <code>src</code> to <code>dest</code>:</p>

<pre class="ruby"><span class="ruby-identifier">tree</span>(<span class="ruby-string">&#39;src0&#39;</span>)
<span class="ruby-comment"># =&gt; src0</span>
<span class="ruby-comment">#    |-- src0.txt</span>
<span class="ruby-comment">#    `-- src1.txt</span>
<span class="ruby-constant">File</span>.<span class="ruby-identifier">exist?</span>(<span class="ruby-string">&#39;dest0&#39;</span>) <span class="ruby-comment"># =&gt; false</span>
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">mv</span>(<span class="ruby-string">&#39;src0&#39;</span>, <span class="ruby-string">&#39;dest0&#39;</span>)
<span class="ruby-constant">File</span>.<span class="ruby-identifier">exist?</span>(<span class="ruby-string">&#39;src0&#39;</span>)  <span class="ruby-comment"># =&gt; false</span>
<span class="ruby-identifier">tree</span>(<span class="ruby-string">&#39;dest0&#39;</span>)
<span class="ruby-comment"># =&gt; dest0</span>
<span class="ruby-comment">#    |-- src0.txt</span>
<span class="ruby-comment">#    `-- src1.txt</span>
</pre>

<p>If <code>src</code> is an array of paths to files and directories and <code>dest</code> is the path to a directory, copies from each path in the array to <code>dest</code>:</p>

<pre class="ruby"><span class="ruby-constant">File</span>.<span class="ruby-identifier">file?</span>(<span class="ruby-string">&#39;src1.txt&#39;</span>) <span class="ruby-comment"># =&gt; true</span>
<span class="ruby-identifier">tree</span>(<span class="ruby-string">&#39;src1&#39;</span>)
<span class="ruby-comment"># =&gt; src1</span>
<span class="ruby-comment">#    |-- src.dat</span>
<span class="ruby-comment">#    `-- src.txt</span>
<span class="ruby-constant">Dir</span>.<span class="ruby-identifier">empty?</span>(<span class="ruby-string">&#39;dest1&#39;</span>)    <span class="ruby-comment"># =&gt; true</span>
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">mv</span>([<span class="ruby-string">&#39;src1.txt&#39;</span>, <span class="ruby-string">&#39;src1&#39;</span>], <span class="ruby-string">&#39;dest1&#39;</span>)
<span class="ruby-identifier">tree</span>(<span class="ruby-string">&#39;dest1&#39;</span>)
<span class="ruby-comment"># =&gt; dest1</span>
<span class="ruby-comment">#    |-- src1</span>
<span class="ruby-comment">#    |   |-- src.dat</span>
<span class="ruby-comment">#    |   `-- src.txt</span>
<span class="ruby-comment">#    `-- src1.txt</span>
</pre>

<p>Keyword arguments:</p>
<ul><li>
<p><code>force: true</code> - if the move includes removing <code>src</code> (that is, if <code>src</code> and <code>dest</code> are on different file systems), ignores raised exceptions of StandardError and its descendants.</p>
</li><li>
<p><code>noop: true</code> - does not move files.</p>
</li><li>
<p><code>secure: true</code> - removes <code>src</code> securely; see details at <a href="FileUtils.html#method-c-remove_entry_secure"><code>FileUtils.remove_entry_secure</code></a>.</p>
</li><li>
<p><code>verbose: true</code> - prints an equivalent command:</p>

<pre class="ruby"><span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">mv</span>(<span class="ruby-string">&#39;src0&#39;</span>, <span class="ruby-string">&#39;dest0&#39;</span>, <span class="ruby-value">noop:</span> <span class="ruby-keyword">true</span>, <span class="ruby-value">verbose:</span> <span class="ruby-keyword">true</span>)
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">mv</span>([<span class="ruby-string">&#39;src1.txt&#39;</span>, <span class="ruby-string">&#39;src1&#39;</span>], <span class="ruby-string">&#39;dest1&#39;</span>, <span class="ruby-value">noop:</span> <span class="ruby-keyword">true</span>, <span class="ruby-value">verbose:</span> <span class="ruby-keyword">true</span>)
</pre>

<p>Output:</p>

<pre class="ruby"><span class="ruby-identifier">mv</span> <span class="ruby-identifier">src0</span> <span class="ruby-identifier">dest0</span>
<span class="ruby-identifier">mv</span> <span class="ruby-identifier">src1</span>.<span class="ruby-identifier">txt</span> <span class="ruby-identifier">src1</span> <span class="ruby-identifier">dest1</span>
</pre>
</li></ul>

                              <div class="method-source-code" id="mv-source">
            <pre><span class="ruby-comment"># File fileutils.rb, line 1157</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">mv</span>(<span class="ruby-identifier">src</span>, <span class="ruby-identifier">dest</span>, <span class="ruby-value">force:</span> <span class="ruby-keyword">nil</span>, <span class="ruby-value">noop:</span> <span class="ruby-keyword">nil</span>, <span class="ruby-value">verbose:</span> <span class="ruby-keyword">nil</span>, <span class="ruby-value">secure:</span> <span class="ruby-keyword">nil</span>)
  <span class="ruby-identifier">fu_output_message</span> <span class="ruby-node">&quot;mv#{force ? &#39; -f&#39; : &#39;&#39;} #{[src,dest].flatten.join &#39; &#39;}&quot;</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">verbose</span>
  <span class="ruby-keyword">return</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">noop</span>
  <span class="ruby-identifier">fu_each_src_dest</span>(<span class="ruby-identifier">src</span>, <span class="ruby-identifier">dest</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">s</span>, <span class="ruby-identifier">d</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">destent</span> = <span class="ruby-constant">Entry_</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">d</span>, <span class="ruby-keyword">nil</span>, <span class="ruby-keyword">true</span>)
    <span class="ruby-keyword">begin</span>
      <span class="ruby-keyword">if</span> <span class="ruby-identifier">destent</span>.<span class="ruby-identifier">exist?</span>
        <span class="ruby-keyword">if</span> <span class="ruby-identifier">destent</span>.<span class="ruby-identifier">directory?</span>
          <span class="ruby-identifier">raise</span> <span class="ruby-constant">Errno</span><span class="ruby-operator">::</span><span class="ruby-constant">EEXIST</span>, <span class="ruby-identifier">d</span>
        <span class="ruby-keyword">end</span>
      <span class="ruby-keyword">end</span>
      <span class="ruby-keyword">begin</span>
        <span class="ruby-constant">File</span>.<span class="ruby-identifier">rename</span> <span class="ruby-identifier">s</span>, <span class="ruby-identifier">d</span>
      <span class="ruby-keyword">rescue</span> <span class="ruby-constant">Errno</span><span class="ruby-operator">::</span><span class="ruby-constant">EXDEV</span>,
             <span class="ruby-constant">Errno</span><span class="ruby-operator">::</span><span class="ruby-constant">EPERM</span> <span class="ruby-comment"># move from unencrypted to encrypted dir (ext4)</span>
        <span class="ruby-identifier">copy_entry</span> <span class="ruby-identifier">s</span>, <span class="ruby-identifier">d</span>, <span class="ruby-keyword">true</span>
        <span class="ruby-keyword">if</span> <span class="ruby-identifier">secure</span>
          <span class="ruby-identifier">remove_entry_secure</span> <span class="ruby-identifier">s</span>, <span class="ruby-identifier">force</span>
        <span class="ruby-keyword">else</span>
          <span class="ruby-identifier">remove_entry</span> <span class="ruby-identifier">s</span>, <span class="ruby-identifier">force</span>
        <span class="ruby-keyword">end</span>
      <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">rescue</span> <span class="ruby-constant">SystemCallError</span>
      <span class="ruby-identifier">raise</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">force</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>

                            <div class="aliases">
                              Also aliased as: <a href="FileUtils.html#method-i-move">move</a>
                            </div>

                          </div>

                  <div id="method-i-pwd" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">pwd</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns a string containing the path to the current directory:</p>

<pre class="ruby"><span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">pwd</span> <span class="ruby-comment"># =&gt; &quot;/rdoc/fileutils&quot;</span>
</pre>

<p>Related: <a href="FileUtils.html#method-c-cd"><code>FileUtils.cd</code></a>.</p>

                              <div class="method-source-code" id="pwd-source">
            <pre><span class="ruby-comment"># File fileutils.rb, line 197</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">pwd</span>
  <span class="ruby-constant">Dir</span>.<span class="ruby-identifier">pwd</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>

                            <div class="aliases">
                              Also aliased as: <a href="FileUtils.html#method-i-getwd">getwd</a>
                            </div>

                          </div>

                  <div id="method-i-remove" class="method-detail method-alias">
                            <div class="method-heading">
                              <span class="method-name">remove</span><span
                                class="method-args">(list, force: nil, noop: nil, verbose: nil)</span>
                            </div>

                            <div class="method-description">
                              

                            </div>


                            <div class="aliases">
                              Alias for: <a href="FileUtils.html#method-i-rm">rm</a>
                            </div>
                          </div>

                  <div id="method-i-remove_dir" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">remove_dir</span><span
                                class="method-args">(path, force = false)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Recursively removes the directory entry given by <code>path</code>, which should be the entry for a regular file, a symbolic link, or a directory.</p>

<p>Argument <code>path</code> should be <a href="FileUtils.html#module-FileUtils-label-Path+Arguments">interpretable as a path</a>.</p>

<p>Optional argument <code>force</code> specifies whether to ignore raised exceptions of StandardError and its descendants.</p>

<p>Related: <a href="FileUtils.html#module-FileUtils-label-Deleting">methods for deleting</a>.</p>

                              <div class="method-source-code" id="remove_dir-source">
            <pre><span class="ruby-comment"># File fileutils.rb, line 1492</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">remove_dir</span>(<span class="ruby-identifier">path</span>, <span class="ruby-identifier">force</span> = <span class="ruby-keyword">false</span>)
  <span class="ruby-identifier">remove_entry</span> <span class="ruby-identifier">path</span>, <span class="ruby-identifier">force</span>   <span class="ruby-comment"># FIXME?? check if it is a directory</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-remove_entry" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">remove_entry</span><span
                                class="method-args">(path, force = false)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Removes the entry given by <code>path</code>, which should be the entry for a regular file, a symbolic link, or a directory.</p>

<p>Argument <code>path</code> should be <a href="FileUtils.html#module-FileUtils-label-Path+Arguments">interpretable as a path</a>.</p>

<p>Optional argument <code>force</code> specifies whether to ignore raised exceptions of StandardError and its descendants.</p>

<p>Related: <a href="FileUtils.html#method-c-remove_entry_secure"><code>FileUtils.remove_entry_secure</code></a>.</p>

                              <div class="method-source-code" id="remove_entry-source">
            <pre><span class="ruby-comment"># File fileutils.rb, line 1449</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">remove_entry</span>(<span class="ruby-identifier">path</span>, <span class="ruby-identifier">force</span> = <span class="ruby-keyword">false</span>)
  <span class="ruby-constant">Entry_</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">path</span>).<span class="ruby-identifier">postorder_traverse</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">ent</span><span class="ruby-operator">|</span>
    <span class="ruby-keyword">begin</span>
      <span class="ruby-identifier">ent</span>.<span class="ruby-identifier">remove</span>
    <span class="ruby-keyword">rescue</span>
      <span class="ruby-identifier">raise</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">force</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">rescue</span>
  <span class="ruby-identifier">raise</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">force</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-remove_entry_secure" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">remove_entry_secure</span><span
                                class="method-args">(path, force = false)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Securely removes the entry given by <code>path</code>, which should be the entry for a regular file, a symbolic link, or a directory.</p>

<p>Argument <code>path</code> should be <a href="FileUtils.html#module-FileUtils-label-Path+Arguments">interpretable as a path</a>.</p>

<p>Avoids a local vulnerability that can exist in certain circumstances; see <a href="FileUtils.html#module-FileUtils-label-Avoiding+the+TOCTTOU+Vulnerability">Avoiding the TOCTTOU Vulnerability</a>.</p>

<p>Optional argument <code>force</code> specifies whether to ignore raised exceptions of StandardError and its descendants.</p>

<p>Related: <a href="FileUtils.html#module-FileUtils-label-Deleting">methods for deleting</a>.</p>

                              <div class="method-source-code" id="remove_entry_secure-source">
            <pre><span class="ruby-comment"># File fileutils.rb, line 1351</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">remove_entry_secure</span>(<span class="ruby-identifier">path</span>, <span class="ruby-identifier">force</span> = <span class="ruby-keyword">false</span>)
  <span class="ruby-keyword">unless</span> <span class="ruby-identifier">fu_have_symlink?</span>
    <span class="ruby-identifier">remove_entry</span> <span class="ruby-identifier">path</span>, <span class="ruby-identifier">force</span>
    <span class="ruby-keyword">return</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-identifier">fullpath</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">expand_path</span>(<span class="ruby-identifier">path</span>)
  <span class="ruby-identifier">st</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">lstat</span>(<span class="ruby-identifier">fullpath</span>)
  <span class="ruby-keyword">unless</span> <span class="ruby-identifier">st</span>.<span class="ruby-identifier">directory?</span>
    <span class="ruby-constant">File</span>.<span class="ruby-identifier">unlink</span> <span class="ruby-identifier">fullpath</span>
    <span class="ruby-keyword">return</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-comment"># is a directory.</span>
  <span class="ruby-identifier">parent_st</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">stat</span>(<span class="ruby-constant">File</span>.<span class="ruby-identifier">dirname</span>(<span class="ruby-identifier">fullpath</span>))
  <span class="ruby-keyword">unless</span> <span class="ruby-identifier">parent_st</span>.<span class="ruby-identifier">world_writable?</span>
    <span class="ruby-identifier">remove_entry</span> <span class="ruby-identifier">path</span>, <span class="ruby-identifier">force</span>
    <span class="ruby-keyword">return</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">unless</span> <span class="ruby-identifier">parent_st</span>.<span class="ruby-identifier">sticky?</span>
    <span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-node">&quot;parent directory is world writable, FileUtils#remove_entry_secure does not work; abort: #{path.inspect} (parent directory mode #{&#39;%o&#39; % parent_st.mode})&quot;</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-comment"># freeze tree root</span>
  <span class="ruby-identifier">euid</span> = <span class="ruby-constant">Process</span>.<span class="ruby-identifier">euid</span>
  <span class="ruby-identifier">dot_file</span> = <span class="ruby-identifier">fullpath</span> <span class="ruby-operator">+</span> <span class="ruby-string">&quot;/.&quot;</span>
  <span class="ruby-keyword">begin</span>
    <span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-identifier">dot_file</span>) {<span class="ruby-operator">|</span><span class="ruby-identifier">f</span><span class="ruby-operator">|</span>
      <span class="ruby-keyword">unless</span> <span class="ruby-identifier">fu_stat_identical_entry?</span>(<span class="ruby-identifier">st</span>, <span class="ruby-identifier">f</span>.<span class="ruby-identifier">stat</span>)
        <span class="ruby-comment"># symlink (TOC-to-TOU attack?)</span>
        <span class="ruby-constant">File</span>.<span class="ruby-identifier">unlink</span> <span class="ruby-identifier">fullpath</span>
        <span class="ruby-keyword">return</span>
      <span class="ruby-keyword">end</span>
      <span class="ruby-identifier">f</span>.<span class="ruby-identifier">chown</span> <span class="ruby-identifier">euid</span>, <span class="ruby-value">-1</span>
      <span class="ruby-identifier">f</span>.<span class="ruby-identifier">chmod</span> <span class="ruby-value">0700</span>
    }
  <span class="ruby-keyword">rescue</span> <span class="ruby-constant">Errno</span><span class="ruby-operator">::</span><span class="ruby-constant">EISDIR</span> <span class="ruby-comment"># JRuby in non-native mode can&#39;t open files as dirs</span>
    <span class="ruby-constant">File</span>.<span class="ruby-identifier">lstat</span>(<span class="ruby-identifier">dot_file</span>).<span class="ruby-identifier">tap</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">fstat</span><span class="ruby-operator">|</span>
      <span class="ruby-keyword">unless</span> <span class="ruby-identifier">fu_stat_identical_entry?</span>(<span class="ruby-identifier">st</span>, <span class="ruby-identifier">fstat</span>)
        <span class="ruby-comment"># symlink (TOC-to-TOU attack?)</span>
        <span class="ruby-constant">File</span>.<span class="ruby-identifier">unlink</span> <span class="ruby-identifier">fullpath</span>
        <span class="ruby-keyword">return</span>
      <span class="ruby-keyword">end</span>
      <span class="ruby-constant">File</span>.<span class="ruby-identifier">chown</span> <span class="ruby-identifier">euid</span>, <span class="ruby-value">-1</span>, <span class="ruby-identifier">dot_file</span>
      <span class="ruby-constant">File</span>.<span class="ruby-identifier">chmod</span> <span class="ruby-value">0700</span>, <span class="ruby-identifier">dot_file</span>
    }
  <span class="ruby-keyword">end</span>

  <span class="ruby-keyword">unless</span> <span class="ruby-identifier">fu_stat_identical_entry?</span>(<span class="ruby-identifier">st</span>, <span class="ruby-constant">File</span>.<span class="ruby-identifier">lstat</span>(<span class="ruby-identifier">fullpath</span>))
    <span class="ruby-comment"># TOC-to-TOU attack?</span>
    <span class="ruby-constant">File</span>.<span class="ruby-identifier">unlink</span> <span class="ruby-identifier">fullpath</span>
    <span class="ruby-keyword">return</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-comment"># ---- tree root is frozen ----</span>
  <span class="ruby-identifier">root</span> = <span class="ruby-constant">Entry_</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">path</span>)
  <span class="ruby-identifier">root</span>.<span class="ruby-identifier">preorder_traverse</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">ent</span><span class="ruby-operator">|</span>
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">ent</span>.<span class="ruby-identifier">directory?</span>
      <span class="ruby-identifier">ent</span>.<span class="ruby-identifier">chown</span> <span class="ruby-identifier">euid</span>, <span class="ruby-value">-1</span>
      <span class="ruby-identifier">ent</span>.<span class="ruby-identifier">chmod</span> <span class="ruby-value">0700</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-identifier">root</span>.<span class="ruby-identifier">postorder_traverse</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">ent</span><span class="ruby-operator">|</span>
    <span class="ruby-keyword">begin</span>
      <span class="ruby-identifier">ent</span>.<span class="ruby-identifier">remove</span>
    <span class="ruby-keyword">rescue</span>
      <span class="ruby-identifier">raise</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">force</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">rescue</span>
  <span class="ruby-identifier">raise</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">force</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-remove_file" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">remove_file</span><span
                                class="method-args">(path, force = false)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Removes the file entry given by <code>path</code>, which should be the entry for a regular file or a symbolic link.</p>

<p>Argument <code>path</code> should be <a href="FileUtils.html#module-FileUtils-label-Path+Arguments">interpretable as a path</a>.</p>

<p>Optional argument <code>force</code> specifies whether to ignore raised exceptions of StandardError and its descendants.</p>

<p>Related: <a href="FileUtils.html#module-FileUtils-label-Deleting">methods for deleting</a>.</p>

                              <div class="method-source-code" id="remove_file-source">
            <pre><span class="ruby-comment"># File fileutils.rb, line 1473</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">remove_file</span>(<span class="ruby-identifier">path</span>, <span class="ruby-identifier">force</span> = <span class="ruby-keyword">false</span>)
  <span class="ruby-constant">Entry_</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">path</span>).<span class="ruby-identifier">remove_file</span>
<span class="ruby-keyword">rescue</span>
  <span class="ruby-identifier">raise</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">force</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-rm" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">rm</span><span
                                class="method-args">(list, force: nil, noop: nil, verbose: nil)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Removes entries at the paths in the given <code>list</code> (a single path or an array of paths) returns <code>list</code>, if it is an array, <code>[list]</code> otherwise.</p>

<p>Argument <code>list</code> or its elements should be <a href="FileUtils.html#module-FileUtils-label-Path+Arguments">interpretable as paths</a>.</p>

<p>With no keyword arguments, removes files at the paths given in <code>list</code>:</p>

<pre class="ruby"><span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">touch</span>([<span class="ruby-string">&#39;src0.txt&#39;</span>, <span class="ruby-string">&#39;src0.dat&#39;</span>])
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">rm</span>([<span class="ruby-string">&#39;src0.dat&#39;</span>, <span class="ruby-string">&#39;src0.txt&#39;</span>]) <span class="ruby-comment"># =&gt; [&quot;src0.dat&quot;, &quot;src0.txt&quot;]</span>
</pre>

<p>Keyword arguments:</p>
<ul><li>
<p><code>force: true</code> - ignores raised exceptions of StandardError and its descendants.</p>
</li><li>
<p><code>noop: true</code> - does not remove files; returns <code>nil</code>.</p>
</li><li>
<p><code>verbose: true</code> - prints an equivalent command:</p>

<pre class="ruby"><span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">rm</span>([<span class="ruby-string">&#39;src0.dat&#39;</span>, <span class="ruby-string">&#39;src0.txt&#39;</span>], <span class="ruby-value">noop:</span> <span class="ruby-keyword">true</span>, <span class="ruby-value">verbose:</span> <span class="ruby-keyword">true</span>)
</pre>

<p>Output:</p>

<pre class="ruby"><span class="ruby-identifier">rm</span> <span class="ruby-identifier">src0</span>.<span class="ruby-identifier">dat</span> <span class="ruby-identifier">src0</span>.<span class="ruby-identifier">txt</span>
</pre>
</li></ul>

<p>Related: <a href="FileUtils.html#module-FileUtils-label-Deleting">methods for deleting</a>.</p>

                              <div class="method-source-code" id="rm-source">
            <pre><span class="ruby-comment"># File fileutils.rb, line 1216</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">rm</span>(<span class="ruby-identifier">list</span>, <span class="ruby-value">force:</span> <span class="ruby-keyword">nil</span>, <span class="ruby-value">noop:</span> <span class="ruby-keyword">nil</span>, <span class="ruby-value">verbose:</span> <span class="ruby-keyword">nil</span>)
  <span class="ruby-identifier">list</span> = <span class="ruby-identifier">fu_list</span>(<span class="ruby-identifier">list</span>)
  <span class="ruby-identifier">fu_output_message</span> <span class="ruby-node">&quot;rm#{force ? &#39; -f&#39; : &#39;&#39;} #{list.join &#39; &#39;}&quot;</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">verbose</span>
  <span class="ruby-keyword">return</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">noop</span>

  <span class="ruby-identifier">list</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">path</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">remove_file</span> <span class="ruby-identifier">path</span>, <span class="ruby-identifier">force</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>

                            <div class="aliases">
                              Also aliased as: <a href="FileUtils.html#method-i-remove">remove</a>
                            </div>

                          </div>

                  <div id="method-i-rm_f" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">rm_f</span><span
                                class="method-args">(list, noop: nil, verbose: nil)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Equivalent to:</p>

<pre class="ruby"><span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">rm</span>(<span class="ruby-identifier">list</span>, <span class="ruby-value">force:</span> <span class="ruby-keyword">true</span>, <span class="ruby-operator">**</span><span class="ruby-identifier">kwargs</span>)
</pre>

<p>Argument <code>list</code> (a single path or an array of paths) should be <a href="FileUtils.html#module-FileUtils-label-Path+Arguments">interpretable as paths</a>.</p>

<p>See <a href="FileUtils.html#method-c-rm"><code>FileUtils.rm</code></a> for keyword arguments.</p>

<p>Related: <a href="FileUtils.html#module-FileUtils-label-Deleting">methods for deleting</a>.</p>

                              <div class="method-source-code" id="rm_f-source">
            <pre><span class="ruby-comment"># File fileutils.rb, line 1241</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">rm_f</span>(<span class="ruby-identifier">list</span>, <span class="ruby-value">noop:</span> <span class="ruby-keyword">nil</span>, <span class="ruby-value">verbose:</span> <span class="ruby-keyword">nil</span>)
  <span class="ruby-identifier">rm</span> <span class="ruby-identifier">list</span>, <span class="ruby-value">force:</span> <span class="ruby-keyword">true</span>, <span class="ruby-value">noop:</span> <span class="ruby-identifier">noop</span>, <span class="ruby-value">verbose:</span> <span class="ruby-identifier">verbose</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>

                            <div class="aliases">
                              Also aliased as: <a href="FileUtils.html#method-i-safe_unlink">safe_unlink</a>
                            </div>

                          </div>

                  <div id="method-i-rm_r" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">rm_r</span><span
                                class="method-args">(list, force: nil, noop: nil, verbose: nil, secure: nil)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Removes entries at the paths in the given <code>list</code> (a single path or an array of paths); returns <code>list</code>, if it is an array, <code>[list]</code> otherwise.</p>

<p>Argument <code>list</code> or its elements should be <a href="FileUtils.html#module-FileUtils-label-Path+Arguments">interpretable as paths</a>.</p>

<p>May cause a local vulnerability if not called with keyword argument <code>secure: true</code>; see <a href="FileUtils.html#module-FileUtils-label-Avoiding+the+TOCTTOU+Vulnerability">Avoiding the TOCTTOU Vulnerability</a>.</p>

<p>For each file path, removes the file at that path:</p>

<pre class="ruby"><span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">touch</span>([<span class="ruby-string">&#39;src0.txt&#39;</span>, <span class="ruby-string">&#39;src0.dat&#39;</span>])
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">rm_r</span>([<span class="ruby-string">&#39;src0.dat&#39;</span>, <span class="ruby-string">&#39;src0.txt&#39;</span>])
<span class="ruby-constant">File</span>.<span class="ruby-identifier">exist?</span>(<span class="ruby-string">&#39;src0.txt&#39;</span>) <span class="ruby-comment"># =&gt; false</span>
<span class="ruby-constant">File</span>.<span class="ruby-identifier">exist?</span>(<span class="ruby-string">&#39;src0.dat&#39;</span>) <span class="ruby-comment"># =&gt; false</span>
</pre>

<p>For each directory path, recursively removes files and directories:</p>

<pre class="ruby"><span class="ruby-identifier">tree</span>(<span class="ruby-string">&#39;src1&#39;</span>)
<span class="ruby-comment"># =&gt; src1</span>
<span class="ruby-comment">#    |-- dir0</span>
<span class="ruby-comment">#    |   |-- src0.txt</span>
<span class="ruby-comment">#    |   `-- src1.txt</span>
<span class="ruby-comment">#    `-- dir1</span>
<span class="ruby-comment">#        |-- src2.txt</span>
<span class="ruby-comment">#        `-- src3.txt</span>
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">rm_r</span>(<span class="ruby-string">&#39;src1&#39;</span>)
<span class="ruby-constant">File</span>.<span class="ruby-identifier">exist?</span>(<span class="ruby-string">&#39;src1&#39;</span>) <span class="ruby-comment"># =&gt; false</span>
</pre>

<p>Keyword arguments:</p>
<ul><li>
<p><code>force: true</code> - ignores raised exceptions of StandardError and its descendants.</p>
</li><li>
<p><code>noop: true</code> - does not remove entries; returns <code>nil</code>.</p>
</li><li>
<p><code>secure: true</code> - removes <code>src</code> securely; see details at <a href="FileUtils.html#method-c-remove_entry_secure"><code>FileUtils.remove_entry_secure</code></a>.</p>
</li><li>
<p><code>verbose: true</code> - prints an equivalent command:</p>

<pre class="ruby"><span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">rm_r</span>([<span class="ruby-string">&#39;src0.dat&#39;</span>, <span class="ruby-string">&#39;src0.txt&#39;</span>], <span class="ruby-value">noop:</span> <span class="ruby-keyword">true</span>, <span class="ruby-value">verbose:</span> <span class="ruby-keyword">true</span>)
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">rm_r</span>(<span class="ruby-string">&#39;src1&#39;</span>, <span class="ruby-value">noop:</span> <span class="ruby-keyword">true</span>, <span class="ruby-value">verbose:</span> <span class="ruby-keyword">true</span>)
</pre>

<p>Output:</p>

<pre>rm -r src0.dat src0.txt
rm -r src1</pre>
</li></ul>

<p>Related: <a href="FileUtils.html#module-FileUtils-label-Deleting">methods for deleting</a>.</p>

                              <div class="method-source-code" id="rm_r-source">
            <pre><span class="ruby-comment"># File fileutils.rb, line 1299</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">rm_r</span>(<span class="ruby-identifier">list</span>, <span class="ruby-value">force:</span> <span class="ruby-keyword">nil</span>, <span class="ruby-value">noop:</span> <span class="ruby-keyword">nil</span>, <span class="ruby-value">verbose:</span> <span class="ruby-keyword">nil</span>, <span class="ruby-value">secure:</span> <span class="ruby-keyword">nil</span>)
  <span class="ruby-identifier">list</span> = <span class="ruby-identifier">fu_list</span>(<span class="ruby-identifier">list</span>)
  <span class="ruby-identifier">fu_output_message</span> <span class="ruby-node">&quot;rm -r#{force ? &#39;f&#39; : &#39;&#39;} #{list.join &#39; &#39;}&quot;</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">verbose</span>
  <span class="ruby-keyword">return</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">noop</span>
  <span class="ruby-identifier">list</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">path</span><span class="ruby-operator">|</span>
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">secure</span>
      <span class="ruby-identifier">remove_entry_secure</span> <span class="ruby-identifier">path</span>, <span class="ruby-identifier">force</span>
    <span class="ruby-keyword">else</span>
      <span class="ruby-identifier">remove_entry</span> <span class="ruby-identifier">path</span>, <span class="ruby-identifier">force</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-rm_rf" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">rm_rf</span><span
                                class="method-args">(list, noop: nil, verbose: nil, secure: nil)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Equivalent to:</p>

<pre class="ruby"><span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">rm_r</span>(<span class="ruby-identifier">list</span>, <span class="ruby-value">force:</span> <span class="ruby-keyword">true</span>, <span class="ruby-operator">**</span><span class="ruby-identifier">kwargs</span>)
</pre>

<p>Argument <code>list</code> or its elements should be <a href="FileUtils.html#module-FileUtils-label-Path+Arguments">interpretable as paths</a>.</p>

<p>May cause a local vulnerability if not called with keyword argument <code>secure: true</code>; see <a href="FileUtils.html#module-FileUtils-label-Avoiding+the+TOCTTOU+Vulnerability">Avoiding the TOCTTOU Vulnerability</a>.</p>

<p>See <a href="FileUtils.html#method-c-rm_r"><code>FileUtils.rm_r</code></a> for keyword arguments.</p>

<p>Related: <a href="FileUtils.html#module-FileUtils-label-Deleting">methods for deleting</a>.</p>

                              <div class="method-source-code" id="rm_rf-source">
            <pre><span class="ruby-comment"># File fileutils.rb, line 1328</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">rm_rf</span>(<span class="ruby-identifier">list</span>, <span class="ruby-value">noop:</span> <span class="ruby-keyword">nil</span>, <span class="ruby-value">verbose:</span> <span class="ruby-keyword">nil</span>, <span class="ruby-value">secure:</span> <span class="ruby-keyword">nil</span>)
  <span class="ruby-identifier">rm_r</span> <span class="ruby-identifier">list</span>, <span class="ruby-value">force:</span> <span class="ruby-keyword">true</span>, <span class="ruby-value">noop:</span> <span class="ruby-identifier">noop</span>, <span class="ruby-value">verbose:</span> <span class="ruby-identifier">verbose</span>, <span class="ruby-value">secure:</span> <span class="ruby-identifier">secure</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>

                            <div class="aliases">
                              Also aliased as: <a href="FileUtils.html#method-i-rmtree">rmtree</a>
                            </div>

                          </div>

                  <div id="method-i-rmdir" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">rmdir</span><span
                                class="method-args">(list, parents: nil, noop: nil, verbose: nil)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Removes directories at the paths in the given <code>list</code> (a single path or an array of paths); returns <code>list</code>, if it is an array, <code>[list]</code> otherwise.</p>

<p>Argument <code>list</code> or its elements should be <a href="FileUtils.html#module-FileUtils-label-Path+Arguments">interpretable as paths</a>.</p>

<p>With no keyword arguments, removes the directory at each <code>path</code> in <code>list</code>, by calling: <code>Dir.rmdir(path)</code>; see Dir.rmdir:</p>

<pre class="ruby"><span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">rmdir</span>(<span class="ruby-node">%w[tmp0/tmp1 tmp2/tmp3]</span>) <span class="ruby-comment"># =&gt; [&quot;tmp0/tmp1&quot;, &quot;tmp2/tmp3&quot;]</span>
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">rmdir</span>(<span class="ruby-string">&#39;tmp4/tmp5&#39;</span>)             <span class="ruby-comment"># =&gt; [&quot;tmp4/tmp5&quot;]</span>
</pre>

<p>Keyword arguments:</p>
<ul><li>
<p><code>parents: true</code> - removes successive ancestor directories if empty.</p>
</li><li>
<p><code>noop: true</code> - does not remove directories.</p>
</li><li>
<p><code>verbose: true</code> - prints an equivalent command:</p>

<pre class="ruby"><span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">rmdir</span>(<span class="ruby-node">%w[tmp0/tmp1 tmp2/tmp3]</span>, <span class="ruby-value">parents:</span> <span class="ruby-keyword">true</span>, <span class="ruby-value">verbose:</span> <span class="ruby-keyword">true</span>)
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">rmdir</span>(<span class="ruby-string">&#39;tmp4/tmp5&#39;</span>, <span class="ruby-value">parents:</span> <span class="ruby-keyword">true</span>, <span class="ruby-value">verbose:</span> <span class="ruby-keyword">true</span>)
</pre>

<p>Output:</p>

<pre>rmdir -p tmp0/tmp1 tmp2/tmp3
rmdir -p tmp4/tmp5</pre>
</li></ul>

<p>Raises an exception if a directory does not exist or if for any reason a directory cannot be removed.</p>

<p>Related: <a href="FileUtils.html#module-FileUtils-label-Deleting">methods for deleting</a>.</p>

                              <div class="method-source-code" id="rmdir-source">
            <pre><span class="ruby-comment"># File fileutils.rb, line 442</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">rmdir</span>(<span class="ruby-identifier">list</span>, <span class="ruby-value">parents:</span> <span class="ruby-keyword">nil</span>, <span class="ruby-value">noop:</span> <span class="ruby-keyword">nil</span>, <span class="ruby-value">verbose:</span> <span class="ruby-keyword">nil</span>)
  <span class="ruby-identifier">list</span> = <span class="ruby-identifier">fu_list</span>(<span class="ruby-identifier">list</span>)
  <span class="ruby-identifier">fu_output_message</span> <span class="ruby-node">&quot;rmdir #{parents ? &#39;-p &#39; : &#39;&#39;}#{list.join &#39; &#39;}&quot;</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">verbose</span>
  <span class="ruby-keyword">return</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">noop</span>
  <span class="ruby-identifier">list</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">dir</span><span class="ruby-operator">|</span>
    <span class="ruby-constant">Dir</span>.<span class="ruby-identifier">rmdir</span>(<span class="ruby-identifier">dir</span> = <span class="ruby-identifier">remove_trailing_slash</span>(<span class="ruby-identifier">dir</span>))
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">parents</span>
      <span class="ruby-keyword">begin</span>
        <span class="ruby-keyword">until</span> (<span class="ruby-identifier">parent</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">dirname</span>(<span class="ruby-identifier">dir</span>)) <span class="ruby-operator">==</span> <span class="ruby-string">&#39;.&#39;</span> <span class="ruby-keyword">or</span> <span class="ruby-identifier">parent</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">dir</span>
          <span class="ruby-identifier">dir</span> = <span class="ruby-identifier">parent</span>
          <span class="ruby-constant">Dir</span>.<span class="ruby-identifier">rmdir</span>(<span class="ruby-identifier">dir</span>)
        <span class="ruby-keyword">end</span>
      <span class="ruby-keyword">rescue</span> <span class="ruby-constant">Errno</span><span class="ruby-operator">::</span><span class="ruby-constant">ENOTEMPTY</span>, <span class="ruby-constant">Errno</span><span class="ruby-operator">::</span><span class="ruby-constant">EEXIST</span>, <span class="ruby-constant">Errno</span><span class="ruby-operator">::</span><span class="ruby-constant">ENOENT</span>
      <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-rmtree" class="method-detail method-alias">
                            <div class="method-heading">
                              <span class="method-name">rmtree</span><span
                                class="method-args">(list, noop: nil, verbose: nil, secure: nil)</span>
                            </div>

                            <div class="method-description">
                              

                            </div>


                            <div class="aliases">
                              Alias for: <a href="FileUtils.html#method-i-rm_rf">rm_rf</a>
                            </div>
                          </div>

                  <div id="method-i-safe_unlink" class="method-detail method-alias">
                            <div class="method-heading">
                              <span class="method-name">safe_unlink</span><span
                                class="method-args">(list, noop: nil, verbose: nil)</span>
                            </div>

                            <div class="method-description">
                              

                            </div>


                            <div class="aliases">
                              Alias for: <a href="FileUtils.html#method-i-rm_f">rm_f</a>
                            </div>
                          </div>

                  <div id="method-i-symlink" class="method-detail method-alias">
                            <div class="method-heading">
                              <span class="method-name">symlink</span><span
                                class="method-args">(src, dest, force: nil, relative: false, target_directory: true, noop: nil, verbose: nil)</span>
                            </div>

                            <div class="method-description">
                              

                            </div>


                            <div class="aliases">
                              Alias for: <a href="FileUtils.html#method-i-ln_s">ln_s</a>
                            </div>
                          </div>

                  <div id="method-i-touch" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">touch</span><span
                                class="method-args">(list, noop: nil, verbose: nil, mtime: nil, nocreate: nil)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Updates modification times (mtime) and access times (atime) of the entries given by the paths in <code>list</code> (a single path or an array of paths); returns <code>list</code> if it is an array, <code>[list]</code> otherwise.</p>

<p>By default, creates an empty file for any path to a non-existent entry; use keyword argument <code>nocreate</code> to raise an exception instead.</p>

<p>Argument <code>list</code> or its elements should be <a href="FileUtils.html#module-FileUtils-label-Path+Arguments">interpretable as paths</a>.</p>

<p>Examples:</p>

<pre class="ruby"><span class="ruby-comment"># Single path.</span>
<span class="ruby-identifier">f</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">new</span>(<span class="ruby-string">&#39;src0.txt&#39;</span>) <span class="ruby-comment"># Existing file.</span>
<span class="ruby-identifier">f</span>.<span class="ruby-identifier">atime</span> <span class="ruby-comment"># =&gt; 2022-06-10 11:11:21.200277 -0700</span>
<span class="ruby-identifier">f</span>.<span class="ruby-identifier">mtime</span> <span class="ruby-comment"># =&gt; 2022-06-10 11:11:21.200277 -0700</span>
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">touch</span>(<span class="ruby-string">&#39;src0.txt&#39;</span>)
<span class="ruby-identifier">f</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">new</span>(<span class="ruby-string">&#39;src0.txt&#39;</span>)
<span class="ruby-identifier">f</span>.<span class="ruby-identifier">atime</span> <span class="ruby-comment"># =&gt; 2022-06-11 08:28:09.8185343 -0700</span>
<span class="ruby-identifier">f</span>.<span class="ruby-identifier">mtime</span> <span class="ruby-comment"># =&gt; 2022-06-11 08:28:09.8185343 -0700</span>

<span class="ruby-comment"># Array of paths.</span>
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">touch</span>([<span class="ruby-string">&#39;src0.txt&#39;</span>, <span class="ruby-string">&#39;src0.dat&#39;</span>])
</pre>

<p>Keyword arguments:</p>
<ul><li>
<p><code>mtime: <em>time</em></code> - sets the entry’s mtime to the given time, instead of the current time.</p>
</li><li>
<p><code>nocreate: true</code> - raises an exception if the entry does not exist.</p>
</li><li>
<p><code>noop: true</code> - does not touch entries; returns <code>nil</code>.</p>
</li><li>
<p><code>verbose: true</code> - prints an equivalent command:</p>

<pre class="ruby"><span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">touch</span>(<span class="ruby-string">&#39;src0.txt&#39;</span>, <span class="ruby-value">noop:</span> <span class="ruby-keyword">true</span>, <span class="ruby-value">verbose:</span> <span class="ruby-keyword">true</span>)
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">touch</span>([<span class="ruby-string">&#39;src0.txt&#39;</span>, <span class="ruby-string">&#39;src0.dat&#39;</span>], <span class="ruby-value">noop:</span> <span class="ruby-keyword">true</span>, <span class="ruby-value">verbose:</span> <span class="ruby-keyword">true</span>)
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">touch</span>(<span class="ruby-identifier">path</span>, <span class="ruby-value">noop:</span> <span class="ruby-keyword">true</span>, <span class="ruby-value">verbose:</span> <span class="ruby-keyword">true</span>)
</pre>

<p>Output:</p>

<pre class="ruby"><span class="ruby-identifier">touch</span> <span class="ruby-identifier">src0</span>.<span class="ruby-identifier">txt</span>
<span class="ruby-identifier">touch</span> <span class="ruby-identifier">src0</span>.<span class="ruby-identifier">txt</span> <span class="ruby-identifier">src0</span>.<span class="ruby-identifier">dat</span>
<span class="ruby-identifier">touch</span> <span class="ruby-identifier">src0</span>.<span class="ruby-identifier">txt</span>
</pre>
</li></ul>

<p>Related: <a href="FileUtils.html#method-c-uptodate-3F"><code>FileUtils.uptodate?</code></a>.</p>

                              <div class="method-source-code" id="touch-source">
            <pre><span class="ruby-comment"># File fileutils.rb, line 2006</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">touch</span>(<span class="ruby-identifier">list</span>, <span class="ruby-value">noop:</span> <span class="ruby-keyword">nil</span>, <span class="ruby-value">verbose:</span> <span class="ruby-keyword">nil</span>, <span class="ruby-value">mtime:</span> <span class="ruby-keyword">nil</span>, <span class="ruby-value">nocreate:</span> <span class="ruby-keyword">nil</span>)
  <span class="ruby-identifier">list</span> = <span class="ruby-identifier">fu_list</span>(<span class="ruby-identifier">list</span>)
  <span class="ruby-identifier">t</span> = <span class="ruby-identifier">mtime</span>
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">verbose</span>
    <span class="ruby-identifier">fu_output_message</span> <span class="ruby-node">&quot;touch #{nocreate ? &#39;-c &#39; : &#39;&#39;}#{t ? t.strftime(&#39;-t %Y%m%d%H%M.%S &#39;) : &#39;&#39;}#{list.join &#39; &#39;}&quot;</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">return</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">noop</span>
  <span class="ruby-identifier">list</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">path</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">created</span> = <span class="ruby-identifier">nocreate</span>
    <span class="ruby-keyword">begin</span>
      <span class="ruby-constant">File</span>.<span class="ruby-identifier">utime</span>(<span class="ruby-identifier">t</span>, <span class="ruby-identifier">t</span>, <span class="ruby-identifier">path</span>)
    <span class="ruby-keyword">rescue</span> <span class="ruby-constant">Errno</span><span class="ruby-operator">::</span><span class="ruby-constant">ENOENT</span>
      <span class="ruby-identifier">raise</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">created</span>
      <span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-identifier">path</span>, <span class="ruby-string">&#39;a&#39;</span>) {
        ;
      }
      <span class="ruby-identifier">created</span> = <span class="ruby-keyword">true</span>
      <span class="ruby-keyword">retry</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">t</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-uptodate-3F" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">uptodate?</span><span
                                class="method-args">(new, old_list)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns <code>true</code> if the file at path <code>new</code> is newer than all the files at paths in array <code>old_list</code>; <code>false</code> otherwise.</p>

<p>Argument <code>new</code> and the elements of <code>old_list</code> should be <a href="FileUtils.html#module-FileUtils-label-Path+Arguments">interpretable as paths</a>:</p>

<pre class="ruby"><span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">uptodate?</span>(<span class="ruby-string">&#39;Rakefile&#39;</span>, [<span class="ruby-string">&#39;Gemfile&#39;</span>, <span class="ruby-string">&#39;README.md&#39;</span>]) <span class="ruby-comment"># =&gt; true</span>
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">uptodate?</span>(<span class="ruby-string">&#39;Gemfile&#39;</span>, [<span class="ruby-string">&#39;Rakefile&#39;</span>, <span class="ruby-string">&#39;README.md&#39;</span>]) <span class="ruby-comment"># =&gt; false</span>
</pre>

<p>A non-existent file is considered to be infinitely old.</p>

<p>Related: <a href="FileUtils.html#method-c-touch"><code>FileUtils.touch</code></a>.</p>

                              <div class="method-source-code" id="uptodate-3F-source">
            <pre><span class="ruby-comment"># File fileutils.rb, line 264</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">uptodate?</span>(<span class="ruby-identifier">new</span>, <span class="ruby-identifier">old_list</span>)
  <span class="ruby-keyword">return</span> <span class="ruby-keyword">false</span> <span class="ruby-keyword">unless</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">exist?</span>(<span class="ruby-identifier">new</span>)
  <span class="ruby-identifier">new_time</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">mtime</span>(<span class="ruby-identifier">new</span>)
  <span class="ruby-identifier">old_list</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">old</span><span class="ruby-operator">|</span>
    <span class="ruby-keyword">if</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">exist?</span>(<span class="ruby-identifier">old</span>)
      <span class="ruby-keyword">return</span> <span class="ruby-keyword">false</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">new_time</span> <span class="ruby-operator">&gt;</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">mtime</span>(<span class="ruby-identifier">old</span>)
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">true</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                          </section>

              </section>
              </main>



            </div>  <!--  class='wrapper hdiv' -->


<footer id="validator-badges" role="contentinfo">
<p><a href="https://validator.w3.org/check/referer">Validate</a></p>
<p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.4.0.</p>
<p>Based on <a href="https://github.com/ged/darkfish/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.</p>

  
    <p><p><a href="https://ruby-doc.org">Ruby-doc.org</a> is provided by <a href="https://jamesbritt.com">James Britt</a> and <a href="https://neurogami.com">Neurogami</a>.</p><p><a href="https://jamesbritt.bandcamp.com/">Maximum R+D</a>.  </p>
</p>
  
  </footer>

<script type="text/javascript">


  let ads  = $("#carbonads-container").children().detach();


  function swapMode() {
    var cookieName = 'darkmode';
    var cssDarkmode = Cookies.get(cookieName);
    console.log("***** swapMode! " + cssDarkmode + " *****");


    if (cssDarkmode == "true") {
      console.log("We have dark mode, set the css to light ...");
      $('#rdoccss').attr("href", defaultModeCssHref);
      $('#cssSelect').text("Dark mode");
      cssDarkmode = "false";
      console.log("swapMode! Now set cookie to " + cssDarkmode);
      Cookies.set(cookieName, cssDarkmode);

    } else {
      console.log("We not have dark mode, set the css to dark ...");
      $('#rdoccss').attr("href", darkModeCsseHref);
      $('#cssSelect').text("Light mode");
      cssDarkmode = "true";
      console.log("swapMode! Now set cookie to " + cssDarkmode);
      Cookies.set(cookieName, cssDarkmode);

    }

    console.log("  --------------- ");
  }


const vueCssApp = new Vue({
el: '#menubar',
data: {
isDark: false
},
methods: {
toggleClass: function(event){
this.isDark = !this.isDark;
}
}
})

const vueApp = new Vue({
el: '#vapp',
data: { 
isOpen: true
},

mounted() {
this.handleResize();
this.manage_mob_classes();
window.addEventListener('resize', this.handleResize)
//this.isOpen !=  (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
},
destroyed() {
window.removeEventListener('resize', this.handleResize)
},
created() {
//manage_mob_classes();
},

methods : {
isMobile() {
  return (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
},

  handleResize() {
    if (!this.isMobile()) {
      this.isOpen = window.innerWidth > 800;
    }
  },

  manage_mob_classes() {
    if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
      $("nav").addClass("mob_nav");
      $("main").addClass("mob_main");
      $("#extraz").addClass("mob_extraz");
      $("#carbonads-container").addClass("mob_carbonads-container");
      this.isOpen  = false;
    } else {
      $("nav").removeClass("mob_nav") 
        $("main").removeClass("mob_main");
      $("#extraz").removeClass("mob_extraz");
      $("#carbonads-container").removeClass("mob_carbonads-container");
      this.isOpen  = true;
    }
  },

  toggleNav() {
    this.isOpen =! this.isOpen ;
    // alert("Toggle nav!");
    console.log("toggleNav() click: " + this.isOpen );
  }
}
})

$("#carbonads-container").append(ads);


$(function() {

    var darkmode = Cookies.get("darkmode");
    console.log("Document ready: " + darkmode);

    if ( darkmode  == "true" ) {
      $('#cssSelect').text("Light mode");
    } else {
      $('#cssSelect').text("Dark mode");
     }

    $('body').css('display','block');
    });

</script>

    
  </body> 
</html>

